doing an inputbegan event, but my walkspeed doesnt change when the condition is met. I have to hold down the key for my walkspeed to be changed despite there not being a condition for the key to be held down.
function LightFire(input)
if input.KeyCode ~= Enum.KeyCode.E or not gui then return else
local lit = gui.Adornee:FindFirstChild("Activated")
if lit.Value == true then
bonfiregui.Enabled = true
humanoid.WalkSpeed = 0
bonfiregui.ExitButton.MouseButton1Down:Connect(function()
bonfiregui.Enabled = false
humanoid.WalkSpeed = 16
end)
end
If this is a LocalScript (which it may be, since it handles the GUI) You will need to find a way to do this server-side. You cannot change server variables like WalkSpeed Client-Side
function LightFire(input)
if input.KeyCode ~= Enum.KeyCode.E or not gui then return else
local lit = gui.Adornee:FindFirstChild("Activated")
if lit.Value == true and gui.Enabled == true then
bonfiregui.Enabled = true
gui.Enabled = false
remoteevent:FireServer(humanoid)
bonfiregui.ExitButton.MouseButton1Down:Connect(function()
bonfiregui.Enabled = false
gui.Enabled = true
remoteevent:FireServer(humanoid)
end)
end
Server Script
game.ReplicatedStorage.Run2.OnServerEvent:connect(function(p, humanoid)
if humanoid.WalkSpeed == 16 then
humanoid.WalkSpeed = 0
elseif humanoid.WalkSpeed == 0 then
humanoid.WalkSpeed = 16
end
end)
Same thing still ends up happening, my walkspeed will only be modified if I hold down the key.
Hello. It would be much easier to help with your issue if you sent the entire script. That way I can break it down and see what’s really going on here.