Script not working for whatever reason

Ello folks! Little issue here. It’s saying that SelectedCar is not a valid member of ReplicatedStorage, but you can see it is in the image below. The script provided below is a local script.

script.Parent.MouseButton1Up:Connect(function(player)
	game.StarterGui["car spawn"].Main.VehicleInfo.CarName.Text = "2018 Horse Stallion"-- Second Problem Here
	game.StarterGui["car spawn"].Main.VehicleInfo.HP.Text = "435" -- Second Problem Here
	game.ReplicatedStorage.CarSystem.SelectedCar game.ReplicatedStorage.CarSystem.Vehicles.Car_Mustang2018  -- Problem Being Caused Here
end)

Another issue is that when you click on 2018 Horse Stallion, it’s supposed to change the CarName and HP text to whatever I set it to.

Thanks!

Alright so what i can see first, is that you are changing the startergui, the startergui is just where you modify the starter guis con roblox studio, then they replicate to playergui, also the second error, is, actually really bad, the code makes no sense, you are just writing the selected car stuff, and the 2018 car thing, I gues you are trying to make the stringvalue change to the car name. So here is the corrected code:


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Playergui =game.Players.LocalPlayer.PlayerGui
script.Parent.MouseButton1Up:Connect(function(player)
	Playergui["car spawn"].Main.VehicleInfo.CarName.Text = "2018 Horse Stallion"-- Second Problem Here
	Playergui["car spawn"].Main.VehicleInfo.HP.Text = "435" -- Second Problem Here
	game.ReplicatedStorage.CarSystem.SelectedCar.Value = game.ReplicatedStorage.CarSystem.Vehicles.Car_Mustang2018.Name  -- Problem Being Caused Here
end)
3 Likes

Fixed it, thanks!

Btw, the SelectedCar was an object value which defined the a car that the player picked which is stored in ReplicatedStorage. At first it didn’t work, but I made the Mustang a variable which made it work… so uh cool?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.