I tried making a script for my racing game and i am getting some annoying errors. I changed the scripts and variables to basically create a NumberValue from an Instance function, then parent it into a car that is spawned by the player in workspace using a GUI (the GUI works just fine), and then the player can type in the textbox to change the performance stats of the car (i.E: Horsepower, which i abbreviated as power) My RemoteEvent is called Horsepower, and since it is only transmitting a 4-number strip directly to a model in the Workspace, there is no need to filter it as it will just break the entire script. My scripting is as follows:

Call script: local replicatedStorage = game:GetService("ReplicatedStorage") local event = replicatedStorage.Horsepower local player = game.Players.LocalPlayer local frame = script.Parent.Parent local box = frame.TextBox

script.Parent.MouseButton1Down:connect(function() event:FireServer(box.Text) end)

Reciever/ServerScriptService script:

game.Workspace.ChildAdded:connect(function() local child = game.Workspace.ChildAdded if child.Name == game.Players.LocalPlayer.Name .. 'sCar' then local name = Instance.new("NumberValue") local Vehicle = game.Workspace.player.Name .. 'sCar' name.Name = "Power" name.Parent = Vehicle local value = name.Value value.Parent = Vehicle end end)

local replicatedStorage = game:GetService("ReplicatedStorage") local event = replicatedStorage.Horsepower

event.OnServerEvent:connect(function(value, newName) value = newName end)

The call script works fine as far as I know, but I commonly get Nil errors in the "value" segment at the bottom of the Reciever script, and whenever i fix the Nil errors they just turn into Index errors. Is it possible you or anyone could help me debug this?

1 comment

0

Format your code.