When I test the game and go in the area pressing e the character's entire inventory is filled. Here is a local script under StarterCharacterScripts:
local uis = game:GetService("UserInputService")
local inArea = false
local player = game.Players.LocalPlayer
workspace.LootBox.AREA.Touched:Connect(function()
inArea = true
print("entered")
workspace.LootBox.Part.BillboardGui.Enabled = true
uis.InputBegan:Connect(function(input)
if input.UserInputType.Name == "Keyboard" and input.KeyCode.Name == "E" and inArea == true then
print("THIS WORKS IF PRINTED")
wait(1)
game.ReplicatedStorage.CloneTool:FireServer(player)
end
end)
end)
workspace.LootBox.AREA.TouchEnded:Connect(function()
workspace.LootBox.Part.BillboardGui.Enabled = false
inArea = false
print("left")
end)
Here is a script under ServerScriptService:
game.ReplicatedStorage.CloneTool.OnServerEvent:Connect(function(player)
local Tool = game.ServerStorage.ClassicSword
local Part = script.Parent
local Clone = Tool:Clone()
Clone.Parent = player.Character
end)
Why is the event firing several times?
