script.Parent.MouseButton1Click:Connect(function() --Change Part with your Brick name
script.Parent.Parent.Parent.Parent.Body.Paint.PAINT.BrickColor = BrickColor.new("Really blue")
end)
I realized, I have a car spawner and when it spawns the car it gets the players name then adds the car to the worspace
example above
basically if some spawns it would be whatever their name is car so i guess i would have to do something like this
script.Parent.MouseButton1Click:Connect(function() --Change Part with your Brick name
game.Workspace.playercar.Body.Paint.PAINT.BrickColor = BrickColor.new("Black")
end)
i used player car as an example.
but im wondering how would i make sure it tells the players name then car. like if idk roblox joined it would say RobloxCar but i would have to make sure the script knows that after workspace.
local playersvehicle = nil
script.Parent.MouseButton1Click:Connect(function() --Change Part with your Brick name
game.Workspace[playersvehicle].Body.Paint.PAINT.BrickColor = BrickColor.new("Black")
end)
sorry im not really to sure. but im now getting this error
This is a good example of why you should not just copy the code. You need to replace nil with the vehicle
Inside the square brackets should be the name of the vehicle (so if the variable playersvehicle is a string (âHiâ) then it will look for something named âHiâ in Workspace as well) But substituting the string with nil gives the error shown above
Just use any string as the variable, and it will look for a child in the workspace with the same name as the string. For example, if playersvehicle = âExampleâ, and there was a part named Example in workspace, then game.Workspace[playersvehicle] would get Example.
Youâre letting this variable be blank, you can then write to this variable later on. In a local script, you should have this:
local namedplayer = nil
namedplayer = game:GetService("Players").LocalPlayer.Name
This will then apply the users name to ânamedplayerâ.
You can use this to fire a remoteevent to the server, which will fire the ânamedplayerâ variable over to the server for further use. Then you can assign the Vehicles name using that variable with an âOnServerEventâ.
Kind of, But Iâm confused why something like what I did before didnât work as planned. Iâll try my best to figure this out though. Thanks for helping guys.