Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to change the property of the player?

Asked by 4 years ago

i want to change the property of the player when he joins the game like making his JumpPower = 65 so how do i do it?

2 answers

Log in to vote
1
Answered by
aredanks 117
4 years ago
Edited 4 years ago
function jumpadd(player) -- function that is connected to the event, the player variable is a parameter that is passed from the event which gives you the player itself which you can access the character by using .Character which accesses that Character in Workspace (once it loads)
    player.CharacterAdded:Wait() -- CharacterAdded is an event as well so it can be connected to a function but here we use it to wait for it instead
    player.Character:WaitForChild("Humanoid") -- Waits for Humanoid to be added in Character
    player.Character.Humanoid.JumpPower = 65 -- edits/changes the property
end
game.Players.PlayerAdded:Connect(jumpadd) -- event to be connected to function

Connect the PlayerAdded event to the function, then wait for character to be added and humanoid to be added which is part of Character then the property JumpPower is part of the Humanoid so change that to 65. This is a server script so create a "Script" for this and not a "LocalScript", you should also place it in ServerScriptService (in Explorer) for it is best used to have server-sided scripts.

PlayerAdded: Fires when a player joins the game

CharacterAdded: Fires when addressed player's character loads in

:WaitForChild(): Waits until named child in paranthesis exists within the addressed object (in this case, Character)

JumpPower: The property you are looking for

Ad
Log in to vote
0
Answered by 4 years ago

game.Players.LocalPlayer.Character.Humanoid.JumpPower = 65

Answer this question