What i want to do is making a tool copy into the player’s backpack after clicking a part. I tried both type of scripts (local and normal) and it doesn’t work.
Here is the script located inside the clickable part :
local ServerStorage = game:GetService("ServerStorage")
local FireExt = ServerStorage:WaitForChild("FireCan")
local clickDetector = script.Parent:WaitForChild("ClickDetector")
local BackPack = game.Players.LocalPlayer.Backpack
function onClick()
local clone = FireExt:Clone()
clone.Parent = BackPack
print("Added to inventory!")
end
clickDetector.MouseClick:Connect(onClick())
Also, is this a problem from my game or from roblox, since i see CoreGui
local ServerStorage = game:GetService("ServerStorage")
local FireExt = ServerStorage:WaitForChild("FireCan")
local clickDetector = script.Parent:WaitForChild("ClickDetector")
function onClick(player)
local clone = FireExt:Clone()
clone.Parent = player.Backpack
print("Added to inventory!")
end
clickDetector.MouseClick:Connect(onClick)
The script works and in order to avoid creating a different topic for the same script, how can i make so the player gets only 1 fire tool ?
Edit : After some quick research i’ve found the solution and explanation. But thank you so much for helping