Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

5 comments

0

oops I spelled success wrong

0

Are you setting the parent of the bus to where you want it?

0

yes

0

You're not, check out Dinoz's addition on line 16 that's what you're missing.

0

oHHHHHHHHHH

1 answer

✓ Accepted answer

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)

1 comment

0

thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.