Please respond, I have been asking for a while now.
I have a code that is supposed to run on Player Added. It's a server script and it's under an image button in Screen GUI. However "hekki" is not printing when I run the program. What's the issue?
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
print("hekki")
script.Parent.MouseButton1Click:Connect(function()
print("hello!")
--local character = player.Character or player.CharacterAdded:Wait()
--local player = game.Players:GetPlayerFromCharacter(Character)
local SG = player.StarterGear
local tool = player.Character:FindFirstChildOfClass("Tool")
--local name = tool.Name
if tool then
print("hello!!!")
tool:Destroy()
end
if SG:FindFirstChild(tool.Name) then
SG[tool.Name]:Destroy()
end
end)
end)

2 comments
What type of script is this?
You actually don't need the Players.PlayerAdded. You only have to put the code into a localscript since this is a script inside a player's screengui and get the player by doing game.Players.LocalPlayer