Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my code not entering the PlayerAdded Event?

Below is a server script. For some reason "hekki" is not being printed at all. The code is supposed to delete the item in hand and also delete that name item from starter gear. Any ideas on why this isn't working?

game.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)

1 comment

0

Is there anything else in the script? It could be yielding and is your script disabled?

1 answer

When I paste your code into my own script it prints "hekki" ? Maybe try replacing:

game.Players...

with:

game:GetService("Players")...

Because sometimes the Players service is not loaded on time for your script to run with.

1 comment

0

It's still not working? any other ideas?

This discussion is preserved as it was. New answers, comments, and votes are closed.