SOLVED How do i fix this script?

I am making a button for my car gui that when you press it it will change the max speed of the car
When you press the button once it will make your car go 105 sps and then when you press it again it will make your car go 295 sps. I made this simple script but it is not working:
image
When the car is entered it moves any gui in the driver seat to the clients startergui so that only the player driving the car can see it. Im sure im doing something wrong. This is the gui element that are copied to startergui when someone is driving the car:
image
Please help me with this i would really appreciate it

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Make it so a gui button can change the speed of a players vehicle

  2. What is the issue? Said gui button is not changing the speed of a players vehicle

  3. What solutions have you tried so far? Rewriting the script and also coming here

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Send the car model, with everything. I’ll try to fix (or someone else can help u)
Oh nevermind i saw your bottom comment, ill try to assist you through it.

It shouldn’t be in an if statement, it should just be

pace.MouseButton1Down:Connect(function()
-- code here
end)
1 Like

If I were you I would just try looking up tutorials on YouTube.

Okay so make make a remote event inside of replicated storage
image
then you’re going to make a local script and replace it with the server script and use this code


local remote = game:GetService("ReplicatedStorage").RemoteEvent
local Button = script.Parent.TextButton

local ButtonClicked = false
Button.MouseButton1Click:Connect(function()
	if ButtonClicked == false then
		ButtonClicked = true
		remote:FireServer()
	elseif ButtonClicked == true then
		ButtonClicked = false
        remote:FireServer()
	end
end)

Then create a serverscript within inside the car
and do this

local ReplicatedStgRemote = game:GetService("ReplicatedStorage").RemoteEvent
local VehicleSeat = script.Parent.VehicleSeat
local RemoteFired = false
local Speed1 = 0
local Speed2 = 0


ReplicatedStgRemote.OnServerEvent:Connect(function()
	if RemoteFired == false then
		RemoteFired = true
		VehicleSeat.MaxSpeed = Speed1
	elseif RemoteFired == true then
		RemoteFired = false
	    VehicleSeat.MaxSpeed = Speed2
	end
end)

test it out and tell me if it don’t work.

1 Like

I just tried it and it did not work so now i dont know what to do
Also looked on youtube for something too and could not find anything

That’s crazy because usually YouTube has a lot of tutorials and stuff.

did you not change the speed 1 and speed 2

and also the parent to the vehicle seat is not the same with yours

send a screenshot of output when you try it out.

Ok i will try and change some things around with it and see if that works

Nice it worked i misplaced a script and it worked Thank you so much

1 Like

No problem, Good day!

– Filling Max Char –

1 Like