#i need this object (coal) when touched to give the player the tool and also work with click
1 messages · Page 1 of 1 (latest)
`local SS = game:GetService("ServerStorage")
local Tool = SS.GiveDrops:FindFirstChild("DropCoal")
local PlayerList = game:GetService("Players")
local Drop = script.Parent
local PickUp = Drop.ClickDetector
function giveTool(player)
local NewTool = Tool:Clone()
NewTool.Parent = player.Backpack
NewTool.Name = "Coal"
Drop:Destroy()
end
PickUp.MouseClick:Connect(function(player)
giveTool(player)
end)
Drop.Touched:Connect(function(player)
local DataPlayer = Players:GetPlayerFromCharacter(Drop.Parent)
print(DataPlayer)
if DataPlayer ~= nil then
print(88)
giveTool(DataPlayer)
end
end)
`
uhh idk how to format it like code on discord
uhh i forgot the problem is that idk how to makae it know its a player so it always errors adn says baseplate cant be given tools
it doesn't work? i checked your script and it seem normal with no error
** You are now Level 1! **
it works in practise but it either dosent give the tool or errors and says baseplate dosent have a backpack
okay i find the error
thanks
Drop.Touched:Connect(function(hit)
local DataPlayer = Players:GetPlayerFromCharacter(hit.Parent)
if not DataPlayer then return end
giveTool(DataPlayer)
end)
try this
juste remove the old touched function and replace with this one
do you have a variable Players? like
local Players = game:GetService("Players")
i save it as PlayerList