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 4 years ago
01local inputLabel = script.Parent
02local inputValue = script.Parent.Parent.Value
03 
04script.Parent.Parent.Enter.Activated:Connect(function()
05    print('Button Pressed')
06    if game.Players:FindFirstChild(inputLabel.Text) then
07        print('Valid Player')       
08        local playerVal = game.Players:FindFirstChild(inputLabel.Text)
09        local valueVal = script.Parent.Parent.Value.Text
10        local character = playerVal.Character
11        local hum = character.Humanoid
12        game.ReplicatedStorage.OwnerInput:FireServer(playerVal, valueVal, character, hum)   
13    else
14            print('Invalid Player')
15    end
16end)

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 4 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

01game.ReplicatedStorage.OwnerInput.OnServerEvent:Connect(function(player, walkSpeedValue)
02    --You only need the player because you can get the character from it
03    local character = player.Character
04 
05    if character then
06        local humanoid = character:FindFirstChild("Humanoid")
07        if humanoid then
08            humanoid.WalkSpeed = walkSpeedValue--Default walkspeed is 16
09        end
10    end
11 
12end)

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 — 4y
Ad

Answer this question