I really wanted to start scriping, so I loaded up output and command bar and typed out
game.Workspace.harleyb09.Head:Destroy()
And it did nothing, not even tell me what was wrong. (I was in play solo) I also tried
game.Workspace.Player1.Head:Destroy()
But still, nothing happened. I feel like such a loser because my first ever script went wrong, please help.
Use this:
function removeHead(plr) --"removeHead is how I chose to name the function and "plr" is the how I chose to name the argument. In this case the event "PlayerAdded" takes the player as an argument. repeat wait() until plr.Character --Loop that repeats the wait() action until the player's character is ready wait(1) --Wait 1 second (added it so it will work for sure) if plr.Character.Name == "Name Here" then --Put player name here plr.Character.Head:Destroy() --Destroy head end end game.Players.PlayerAdded:connect(removeHead) --Calling the function using a connection line which contains the PlayerAdded event
I think your scripts didn't work because they were executed before the player even joined the game.
The following script runs a function once a player entered the game.
You will learn more about functions, if statements and loops in the future.
Haven't scripted in RBX.LUA for a few months now but I think it should work.
The first one does not work because if you are in play solo mode, you will spawn as Player1. It worked for me. Also, don't feel upset, it'll come with time :).
If it is still not working, try this:
game.Players.LocalPlayer.Character.Head:Destroy()
Keep in mind, if you were to place this in a server sided script it will not work. But since you're only beginning to script and you're just using the output it will do just fine.