Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Car Spawner (Cloned Car rename to Players Name)?

Asked by 2 years ago
Edited 2 years ago

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)
0
The Car Spawns currently with the Name "AudiS3" in the Workspace. And if im set the (Clone.Name = player.Name.. "s AudiS3") over the (Clone.Parent = workspace), then the car dosnt spawn zEmirYT 7 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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)
0
Thats it, thanks! zEmirYT 7 — 2y
Ad

Answer this question