Hello, I am trying to make a car spawner gui for my testing game. Here's the code.
script.Parent.MouseButton1Click:connect(function(GetCar) local Mod = game.ServerStorage.ToyotaChaser --Change test to whatever you have named the item you want to spawn local clone = Mod:clone() clone.Parent = workspace clone:MakeJoints() end)
But it gives me an error, and says ToyotaChaser is not a valid member of ServerStorage, even though there's a model named ToyotaChaser in ServerStorage.
reading the simple script what you did wrong is store the car in ServerStorage! when instances are placed in the ServerStorage it will store everything in the server not the client! to fix this make sure that your connect is spelt with a capital! change your Mod variable to
local Mod = game.ReplicatedStorage.ToyotaChaser
as well make sure the model is in the ReplicatedStorage!
script.Parent.MouseButton1Click:Connect(function(GetCar) local Mod = game.ReplicatedStorage.ToyotaChaser --Change test to whatever you have named the item you want to spawn local clone = Mod:clone() clone.Parent = workspace clone:MakeJoints() end)
im pretty sure that will work! your welcome. :)
Before all of this, I'm assuming this is a local script,
MouseButton1Click does not pass an argument,
:connect is deprecated, use
:Connect, since this is a local script, it can only access client sided stuff, but
ServerStorage is server sided, so it doesn't exist in this script, put the
game.ReplicatedStorage and locate
Mod like this:
local Mod = game.ReplicatedStorage.ToyotaChaser, and this will only show for the client, if you need it to show for everyone, use a remote event
I'll use a normal Script instead.