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

How do I make a function play using an 'if' statement?

Im trying to make a rickroll prank game (yea yea)

But the script to play 'Never Gonna Give You Up' isn't working. Im fairly new to if statements myself, sorry if I seem stupid to you.

Script:

local Player = game:GetService("Players").LocalPlayer

function RickRoll()
	game.Workspace.Sound.Play()
end

if Player.PlayerAdded then
	wait(5)
	RickRoll()
end

1 answer

The PlayerAdded signal is home to the Players Service, you’re trying to reference it through a Player Object. It shouldn’t necessarily be used as a conditional either though, since it’s an RBXScriptSignal you can simply just run the code as an event:

local Players = game:GetService("Players")

local Sound = workspace:WatForChild("Sound")

local function RickRoll()
    wait(5); Sound:Play()
end

Players.PlayerAdded:Connect(RickRoll)

1 comment

0

Sorry for the late respose but I figured it out myself, lol. Have some free rep tho

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