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

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

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

✓ Accepted answer

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!

1 comment

0

Thank You

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