Hello! im scripting an Car Spawner. But im not sure why the script is not working.
I want make, that if you click at the button, that a cloned car from the ServerStorage the Name from the player has (Owner).
May someone can help me
My script:
local Button = script.Parent.Parent.Button local player = game:GetService("Players").localPlayer Button.MouseButton1Click:Connect(function() local enabled = false if enabled == false then enabled = true local Mod = game.ServerStorage['AudiS3'] local clone = Mod:clone() clone.Parent = workspace clone:MakeJoints() clone.Name = player.Name.. "s AudiS3" wait(15) enabled = false end end)
You cannot access ServerStorage from a LocalScript! What you will need to do is create a RemoteEvent in ReplicatedStorage called "SpawnCar".
Then in your local script:
local Button = script.Parent.Parent.Button local player = game:GetService("Players").localPlayer local Event = game.ReplicatedStorage.SpawnCar Button.MouseButton1Click:Connect(function() local enabled = false if enabled == false then enabled = true Event:FireServer() wait(15) enabled = false end end)
Create a server script called "SpawnCar"
local Event = game.ReplicatedStorage.SpawnCar Event.OnServerEvent:Connect(function(player) local Mod = game.ServerStorage['AudiS3'] local clone = Mod:clone() clone.Parent = workspace clone:MakeJoints() clone.Name = player.Name.. "s AudiS3" end)