So, I am trying to make am attempting to make a police radar system, I am using an A-Chassis Vehicle and I created a string value inside of the car that showcases the current speed of the car.
and I have an invisible block that when touched by the other car gets the value of the other car it is touching, It only shows the default value and not the changed value… I was thinking that it’s not working because the string value is only changing on the client. I attempted to use a remote event but I confused myself. I got rid of the remote event stuff and this is what the script that was inside the block being touched.
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChild("SpeedValue") then
while true do
print(hit:FindFirstChild("SpeedValue").Value)
wait(1)
end
end
end)
And this is the script that tells the speed value to change with the cars speed value
it was a local script placed inside of the Speed Textbutton that gets cloned into the players gui.
if script.Parent.Parent.Parent.Parent == game.Players.LocalPlayer.PlayerGui then
print("Hi")
wait()
local carvalue = script.Parent.Parent.Parent.Car.Value
while true do
carvalue.DriveSeat.SpeedValue.Value = script.Parent.Text
wait()
end
I’m almost 90% sure I need a remote event, if it is please help me. I really confused myself hard…
This is unwise. Now, every time the script.Parent is touched, it’ll start a new loop. Touched can fire many times, so you’ll probably crash the game. If you want to get a changing value, you could do
local function printSpeed(value)
print(value)
end
carvalue.DriveSeat.SpeedValue.Changed:Connect(printSpeed)
It sounds like to me that you may not realise that local script inputs are filtered out from the workspace. In other words changes to any instance that is under the workspace (excluding player ownership Baseparts and characters) will not be detected on a regular script.
To fix this you either should read the A Chassis docs (if there is one) to find out how speed is calculated or you can use a different measurement of speed. Such as
local Speed = Car.PrimaryPart.AssemblyLinearVelocity.Magnitude
print(Speed)
(A model car with a primary part is required. Measurement in studs per sec.)
Yikes. I would not recommend doing that getting information from client GUI is risky.
What I would do is to find out another way you can directly retrieve the speed of the car through the server script only.