This is really annoying me. I was trying to make the player jump in a script when they clicked a button, but output just says "attempt to index nil with 'Character'". It's in a server side script, and the local player had already been addressed and everything. I have tried this:
lp = game.Players.LocalPlayer lpc = lp.Character
and this:
lpc = game.Players.LocalPlayer.Character
also this...
lp = game.Players.LocalPlayer lpc = game.Workspace:FindFirstChild(lp.Name)
this was the code for the jump... (inside of a function)
lpc.Humanoid.Jump = true
Why does this keep happening? Why does it work in scripts other than mine? I'm only getting errors for this part of the script. If you need me to release the whole script, I will.
Clickdetectors have an argument in the MouseClick event that passes the player that clicked it. From there you can call their character and humanoid.
--server script Part = script.Parent function onClick(plr) plr.Character.Humanoid.Jump = true end Part.ClickDetector.MouseClick:Connect(onClick)
You cannot use the local player in a server script - only in a local script.
To get around this, you can use remote events.
Create a remote event in the workspace with a server script listening to it. Have a button that fires the event on the client, and you've got yourself a working jump button.