attempt to index nil with character, the script should work this way, u touch it and it anchores your head, it isnt really what i need to do completely
01 | local part = workspace.ts 4 |
02 |
03 | part.Touched:wait() |
04 |
05 | player.Character.Head.Anchored = true |
06 |
07 | function onPartTouched() |
08 | player.Character.Head.Anchored = true |
09 | end |
10 |
11 | part.Touched:connect(onPartTouched) |
the ''player'' is blue below that i think its nil btw dont take down, i tried
player is a variable you have to set. You can get it by using game.Players:GetPlayerFromCharacter(model), which returns nil if the model isn't from a player character. It can be set in localscripts with local player = game.Players.LocalPlayer. BUT you are using a part.Touched event, so you don't need a player unless you want to mess with it too or to rule out npcs. Set a variable for the touched part:
1 | player.Character.Head.Anchored = true |
2 |
3 | function onPartTouched(touch) |
4 | if touch.Parent:findFirstChild( "Humanoid" ) then --makes sure part is from a humanoid |
5 | touch.Parent.Head.Anchored = true |
6 | end |
7 | end |
8 |
9 | part.Touched:connect(onPartTouched) |