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

Where can I go from what I have to edit a Value of a players humanoid?

Asked by 3 years ago
local inputLabel = script.Parent
local inputValue = script.Parent.Parent.Value

script.Parent.Parent.Enter.Activated:Connect(function()
    print('Button Pressed')
    if game.Players:FindFirstChild(inputLabel.Text) then
        print('Valid Player')        
        local playerVal = game.Players:FindFirstChild(inputLabel.Text)
        local valueVal = script.Parent.Parent.Value.Text
        local character = playerVal.Character
        local hum = character.Humanoid
        game.ReplicatedStorage.OwnerInput:FireServer(playerVal, valueVal, character, hum)    
    else
            print('Invalid Player')
    end
end)

I'm trying to edit the speed of the player who was input into a textbox, how does one accomplish this in the Server Script receiving the RemoteEvent

1 answer

Log in to vote
1
Answered by 3 years ago

In order to change the speed of the player, you would first connect the OwnerInput event to a function. Then, you would just change the walk speed of the humanoid of that player using Player.Character.Humanoid.Walkspeed

game.ReplicatedStorage.OwnerInput.OnServerEvent:Connect(function(player, walkSpeedValue) 
    --You only need the player because you can get the character from it 
    local character = player.Character

    if character then
        local humanoid = character:FindFirstChild("Humanoid")
        if humanoid then
            humanoid.WalkSpeed = walkSpeedValue--Default walkspeed is 16
        end 
    end 

end)

So this should answer your question. Keep in mind that you will have to set the walkspeed each time the character spawns in. Also, instead of sending so many variables in the remote event, I would just send the walk speed since remote events automatically send the player. This should simplify your code. If you are wondering why I have so many if statements to check for basic things, the reason is that you can never be too careful with humanoids (trust me I have experience).

Hope this helps!

0
Thank You zboi082007 270 — 3y
Ad

Answer this question