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

Why does my script print "Success" but doesn't do the thing it was attended to do?

Asked by 5 years ago

So here is my script(in ServerScriptService):

local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local spawnEvent = events:WaitForChild("Spawn")

local rs = game:GetService("ReplicatedStorage")
local buses = workspace:WaitForChild("ShopBuses")

local rtaBus = buses:WaitForChild("RTABus")

local busSpawn = workspace:WaitForChild("BusSpawn")

spawnEvent.OnServerEvent:connect(function(plr,msg)
    local clone = rtaBus:Clone()

    clone:SetPrimaryPartCFrame(busSpawn.CFrame)

    if clone then
        print("Sucess!")
    end
end)

How it is suppose to work:

1)Player presses spawn button

2)Event(spawnEvent) gets fired

3)Bus gets spawned --Doesn't do it

The script does print "Success" but the bus doesn't spawn.

The script is running of a event in Replicated Storage(it works)

So what's wrong?

0
oops I spelled success wrong FriendlyLolli123 37 — 5y
0
Are you setting the parent of the bus to where you want it? WizyTheNinja 834 — 5y
0
yes FriendlyLolli123 37 — 5y
0
You're not, check out Dinoz's addition on line 16 that's what you're missing. GoodCallMrOlsen 70 — 5y
0
oHHHHHHHHHH FriendlyLolli123 37 — 5y

1 answer

Log in to vote
3
Answered by 5 years ago
Edited 5 years ago

Need to parent clone to workspace

local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local spawnEvent = events:WaitForChild("Spawn")

local rs = game:GetService("ReplicatedStorage")
local buses = workspace:WaitForChild("ShopBuses")

local rtaBus = buses:WaitForChild("RTABus")

local busSpawn = workspace:WaitForChild("BusSpawn")

spawnEvent.OnServerEvent:Connect(function(plr,msg)
    local clone = rtaBus:Clone()

    clone.Parent = workspace
    clone:SetPrimaryPartCFrame(busSpawn.CFrame)

    if clone then
        print("Sucess!")
    end
end)
0
thank you FriendlyLolli123 37 — 5y
Ad

Answer this question