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

jumping by text button wont work?

local button = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

button.MouseButton1Click:Connect(function()
	Humanoid.Jump = true
end)

3 comments

0

Are you using this as a localscript or a script? If a normal script, localplayer cannot be used in server scripts

0

i using local script

0

Try using mouse1buttondown instead, not mousebutton1click

1 answer

Your issue, based on what you said in your comments, is that you're jumping the player via LocalScript. You need to fire a RemoteEvent to the server and have the player jump server-side.

The script you already have, your LocalScript should look something like this:

local button = script.Parent
local LocalPlayer = game.Players.LocalPlayer

local remote = Instance.new("RemoteEvent")
remote.Name = "Jump"
remote.Parent = game.ReplicatedStorage

button.MouseButton1Click:Connect(function()
	remote:FireServer(LocalPlayer) -- We're sending the player to the server, so the server knows who to jump.
end)

Then, you want a server script looking something like this to make it happen:

local remote = game.ReplicatedStorage:WaitForChild("Jump")

remote.OnServerEvent:Connect(function(playerToJump)
	playerToJump.Character:FindFirstChildOfClass("Humanoid").Jump = true
end)

In summary, your LocalScript tells the server when the player presses the button. Your regular script (server script) actually makes the jump happen.

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