-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainServer.lua
More file actions
63 lines (46 loc) · 1.82 KB
/
MainServer.lua
File metadata and controls
63 lines (46 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
local DataStoreService = game:GetService("DataStoreService")
local playerStore = DataStoreService:GetDataStore("PlayerInventory")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InventoryHandler = require(ReplicatedStorage.Shared.PlayerInventoryHandler)
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local ReadData = ReplicatedStorage.DataStoreEvents.ReadData
local DeleteData = ReplicatedStorage.DataStoreEvents.DeleteData
local DropSword = ReplicatedStorage.SwordEvents.DropSword
local Workspace = game:GetService("Workspace")
-- when player joins create the players inventory
-- Then visualize it
-- Player clicks or touches object
-- Read inventory
-- When touch object it updates the inventory
-- When player clicks on object in inventory it drops the object
Players.PlayerAdded:Connect(function(plr)
local playerId = plr.UserId
InventoryHandler.Init(playerId)
end)
ReadData.OnServerInvoke = function(player)
local playerId = player.UserId
local data = InventoryHandler.Read(playerId)
return data
end
DeleteData.OnServerEvent:Connect(function(player, item)
local plrId = player.UserId
local playerInventory = InventoryHandler.Read(plrId)
for i, v in playerInventory do
if item == v then
table.remove(playerInventory, i)
InventoryHandler.Write(plrId, playerInventory)
return
end
end
print("hacker")
return "exploiter"
end)
DropSword.OnServerEvent:Connect(function(plr)
local plrId = plr.UserId
local storageOriginal = ReplicatedFirst.SwordPack
local copyOfSword = storageOriginal:Clone()
local humanRoot = plr.Character.HumanoidRootPart.Position
copyOfSword.Parent = Workspace
copyOfSword.Handle.Position = Vector3.new(humanRoot.X + 2, humanRoot.Y, humanRoot.Z)
end)