So this is my script:
function playerAdded(player) local sv = Instance.new("StringValue") sv.Parent = game.Workspace sv.name = "IsItBep" wait(1) local stringv = game.Workspace.IsItBep game.Workspace.IsItBep.Value = player.Name() wait(0.1) if game.Workspace.IsItBep.Value == "Bep0man" then local m = Instance.new("Message") m.Parent = game.Workspace m.Name = "ItsBep0" wait(0.5) local me = game.Workspace.ItsBep0 me.Text = "OMGGGGG GRAB YOUR MOUNTAIN DEW AND DORITOS!!! BEP0MAN IS ON THE GAME!!!!! OMOMGOMGOMGOMGGG SNOOP DOGG" wait(4) me.Text = "NO RLLY ITS SO EPIK LIKE 9000!!! (HEAD EXPLODES FORM EPIKNESS)" wait(4) me:Destroy() game.Workspace.IsItBep:Destroy() else game.Workspace.IsItBep:Destroy() end end
Does anyone know why it's not working?
That code will never run in a billion years.
Functions only run when they are called. Calling a function means asking it to run by putting two parentheses after its name:
function sayHi() print("Hi") end sayHi() --This makes it run
There's nothing special about naming your function playerAdded
. It's just a normal function that won't run until you tell it to.
But you don't want your function to only run once, you want it to run when a player joins. This is why we use an event. Connecting a function to an event will make it so that Roblox calls it when the event fires.
We connect the PlayerAdded event to our function:
function sayHi() print("Hi") end game.Players.PlayerAdded:connect(sayHi)
Now it will run when someone joins.
Another problem lies with line 07,
game.Workspace.IsItBep.Value = player.Name()
Name
is a property, so we shouldn't use parentheses to access it. Instead, write:
game.Workspace.IsItBep.Value = player.Name
But we can take this out entirely just by checking the name directly:
if player.Name == "Bep0man" then
And you have a lot of pointless variables, for example, you wrote:
local m = Instance.new("Message") m.Parent = game.Workspace m.Name = "ItsBep0" wait(0.5) local me = game.Workspace.ItsBep0
While you could just keep using the variable m
.
And,
local sv = Instance.new("StringValue") sv.Parent = game.Workspace sv.name = "IsItBep" wait(1) local stringv = game.Workspace.IsItBep
While you could just keep using the variable sv
.