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

the script worked correctly till i added that if statment so what happened ?

Asked by
hmurban 16
6 years ago

its a server-sided script in the serverscriptservice. it should create a boolvlaue inside the player and it worked

plr = game.Players:GetPlayerFromCharacter(player)
game.Players.PlayerAdded:Connect(function(player)
local vip = Instance.new("BoolValue")
 vip.Parent = player
 vip.Name = "vip"
end)

but when i added the if statment it didn't work and there is no errors in the output..

plr = game.Players:GetPlayerFromCharacter(player)
game.Players.PlayerAdded:Connect(function(player)
if player.Name == hmurban then
local vip = Instance.new("BoolValue")
 vip.Parent = player
 vip.Name = "vip"
end
end)
0
What is player defined as on line 1? User#19524 175 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

hmurban would be a variable, and you might want to do it like

hmurban = "hmurban"
plr = game.Players:GetPlayerFromCharacter(player)
game.Players.PlayerAdded:Connect(function(player)
if player.Name == hmurban then
local vip = Instance.new("BoolValue")
 vip.Parent = player
 vip.Name = "vip"
end
end)

Your code should be: which is shorter

plr = game.Players:GetPlayerFromCharacter(player)
game.Players.PlayerAdded:Connect(function(player)
if player.Name == "hmurban" then
local vip = Instance.new("BoolValue")
 vip.Parent = player
 vip.Name = "vip"
end
end)

1
thanks that worked ^^ hmurban 16 — 6y
Ad

Answer this question