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

DescendantAdded function is not working/firing?

So I basically have this script in my PlayerGui

I do not get an error when i run this and it wont run the print.

I need help

local player = game.Players.LocalPlayer
script.Parent.DescendantAdded:Connect(function(child)
	print(child.Name)
	player:Kick("You try hack. You die")
end)

4 comments

0

and ik its noot good to kick players from a local script but im transfering later

0

The reason you dont get an error is because theres no need of localplayer if your not talking about the character,tool or guis.

0

this is a script in the player gui its used to detect if a player gui is added and then kick the player if a player gui is added

0

sorry for the late reply btw. and its a local script

1 answer

Make sure this is in starterplayerscript You don't need localplayer. Local player is basically used for tools, characters and guis not a playeradded event. DesecendantAdded is depreciated use PlayerAdded instead This wouldn't work on a local script because the client can't kick a player if you want it to then use a remote event.

I edited it Make sure this is in serverscriptservice.

game.Players.PlayerAdded:Connect(function(player)
wait (1)
print (player.Name) 
player:Kick( "You try hack. You die") 
end)

3 comments

0

The script is located in StarterGui and is ment to check if the player has added a gui with an expoit.

0

Try using a remote event

0

I edited it if it helped accept my answer.

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