But I do in all of these?
characters
How so? Is the leftMouse variable already set to true before the player does anything?
No, are you proposing this change?
function leftOn()
local direction = "Left"
left.MouseButton1Down:Connect(function()
leftMouse = true
while leftMouse == true do
game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
task.wait()
end
end)
end
function leftOn()
local direction = "Left"
left.MouseButton1Down:Connect(function()
leftMouse = true
end)
while leftMouse == true do
game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
task.wait()
end
end
something like this?
function leftOn()
local direction = "Left"
local leftMouse = nil
left.MouseButton1Down:Connect(function()
leftMouse = true
end)
left.MouseButton1Up:Connect(function()
leftMouse = false
end)
while leftMouse == true do
game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
task.wait()
end
sorry, I forgot a few end
s (replying to my reply above)
Oh I already have one for it, and it still doesn’t work
function leftOff()
local direction = "Left"
left.InputEnded:Connect(function()
leftMouse = false
game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
end)
left.InputChanged:Connect(function(input)
if input.UserInputState == Enum.UserInputState.Cancel then
leftMouse = false
game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
end
end)
left.MouseButton1Up:Connect(function()
leftMouse = false
game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
end)
left.TouchTap:Connect(function()
leftMouse = true
game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
task.wait()
leftMouse = false
game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
wait()
leftMouse = false
game.ReplicatedStorage.CarThrottle:FireServer(direction, leftMouse)
end)
end
leftMouse is a global variable
Yeah, but leave the MouseButton1Down and while loop outside the function
Ok, I see what you are saying, but how would it make a difference if the leftMouse = false won’t fire? I’ll still try it though.
take all the functions inside leftOff()
outside of it
it fires because it’s in its own thread now. it won’t wait for others to finish to run
I have to put them in there though because then the left variable destroy and won’t fire again when a player resets.
oh, so the script doesn’t reset, but the UI does?
? when a player resets, all code is cloned and reset-ed as well
Correct
Characters Characters Characters
No, the script is in the playerscripts, so it doesn’t reset, however when a player respawns then the UI resets. I can try changing this, but I don’t think it would make a difference.
Oh, ok then. I suggest, if you can, put the script inside the UI, or just put the while loop outside the function that way at least that won’t cause much of an issue.
put the script into player GUI. It needs to always respawn with GUI (since it’s manipulating GUI).
otherwise, you can clone it to player gui?
doing so would solve many inconveniences
Actually, just re-assign the variable when the function is called. I’ve had that issue occur many times before. But still, put the loop outside the function.
Ok sure no problem, I will also say, that these are all fired when the UI is reset so there isn’t any waiting, so putting outside wouldn’t really change anything from that perspective