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

What Is Wrong With My 'ElseIf' Statement?

Here is my code:

wait(30)
Workspace.Tick:Play()
Workspace.GUIPart.SurfaceGui.Frame.TextLabel.Text = "No one has won? What a Pity..."
Workspace.Funny:Play()
for i, v in pairs(game.Players:GetPlayers()) do
pcall(function() v.Character.Torso.CFrame = CFrame.new(Vector3.new(63, 0, 100)) end) 
end
	wait(10)
end

elseif script.Parent.Parent.Parent.Character:OnTouched(Workspace.Map1.Touching)then
	for i, v in pairs(game.Players:GetPlayers()) do
pcall(function() v.Character.Torso.CFrame = CFrame.new(Vector3.new(63, 0, 100)) end) 
Workspace.Tick:Play()
Workspace.GUIPart.SurfaceGui.Frame.TextLabel.Text = "<[NamesNotImplementedYet]> Has Won The Round!"
wait(5)
	end

'Tick' and 'Funny' are soundtracks in the game. On the elseif statement, when the players touch a part they spawn back to the lobby and they win. But for some reason mine doesn't work. Anyone help me?

1 comment

0

Im wondering why the elseif statement is even needed. Considering there is no "if". It may be too advanced for me, but I don't see why it is needed.

1 answer

I only fixed the main problem, just add this part to your script instead of the elseif .

function script.Parent.Parent.Parent.Character.Touched:connect(function()--you need to call a function here not a if or elseif
    for i, v in pairs(game.Players:GetPlayers()) do
pcall(function() v.Character.Torso.CFrame = CFrame.new(Vector3.new(63, 0, 100)) end) 
Workspace.Tick:Play()
Workspace.GUIPart.SurfaceGui.Frame.TextLabel.Text = "<[NamesNotImplementedYet]> Has Won The Round!"
wait(5)
    end)

also please only put the part of the script that has a problem not the whole script.

2 comments

0

Thank you for your help.

0

sorry for the typo

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