of     1   

excellentAnarchy
#175511308Sunday, October 04, 2015 12:54 PM GMT

The below code must be wrong, and I believe it's something to do with my use of elseif statements, could someone check it? The script prints "not creator", even though it shouldn't. Function: I want the script to check for vip3, vip2 and vip1, if they're present, remove them and clone the 'creator' into the Player's head. local Names = {cokePanda = true} local creator = game.ServerStorage.creator:Clone() game.Players.PlayerAdded:connect(function(p) local char = p.CharacterAdded:connect(function(char) if Names[p.Name] then local vip3 = char.Head:findFirstChild("vip3") local vip2 = char.Head:findFirstChild("vip2") local vip1 = char.Head:findFirstChild("vip1") if vip3 then vip3:Remove() elseif vip2 then vip2:Remove() elseif vip1 then vip1:Remove() creator.Parent = char.Head print("is creator") else print("not creator") end end end) end)
FlyNormal
#175512017Sunday, October 04, 2015 1:11 PM GMT

Your code is overall fine. But one problem I see in your code is that you're using if statements as "or" not "and". In depth you're checking ONLY if any of the VIPs exists and not if all of them exist together. To do that, use the "and" operator. if (vip1 and vip2 and vip3) then -- do stuff end
excellentAnarchy
#175512404Sunday, October 04, 2015 1:20 PM GMT

I need the script to check if the player owns any of these vips, not all of them together. So, if any of those vips exist, I need them removed, and then the creator should be parented to the Player's head.
FlyNormal
#175512481Sunday, October 04, 2015 1:22 PM GMT

Oh, then this code should resolve your issue: game.Players.PlayerAdded:connect(function(p) local char = p.CharacterAdded:connect(function(char) if Names[p.Name] then local vip3 = char.Head:FindFirstChild("vip3") local vip2 = char.Head:FindFirstChild("vip2") local vip1 = char.Head:FindFirstChild("vip1") if (vip1) then vip1:Destroy() end if (vip2) then vip2:Destroy() end if (vip3) then vip3:Destroy() end creator.Parent = char.Head end end) end)
excellentAnarchy
#175514318Sunday, October 04, 2015 2:00 PM GMT

This isn't working :/
excellentAnarchy
#175514520Sunday, October 04, 2015 2:03 PM GMT

I think I got it.
lostend
#175516390Sunday, October 04, 2015 2:37 PM GMT

var Names=[cookPanda=true] var Creator=document.getElementById('creator'):clone() document.getElementById('Players').addEventListener('joined',function(p){ p.addEventListener('charloaded',function(c){ if Names[p.Name]{ var vip3 = char.Head.getElementById('vip3') var vip2 = char.Head.getElementById('vip2') var vip1 = char.Head.getElementById('vip1') if (vip3){ vip3.innerHTML=null }else if(vip2){ vip2.innerHTML=null }else if(vip1){ vip1.innerHTML=null creator.Parent = char.Head console.log('is creator') } } }) })
excellentAnarchy
#175517958Sunday, October 04, 2015 3:02 PM GMT

local Names = {cokePanda = true} local creator = game.ServerStorage.creator:Clone() game.Players.PlayerAdded:connect(function(p) local char = p.CharacterAdded:connect(function(char) if Names[p.Name] then repeat wait() until char wait(3) local vip3 = char.Torso:FindFirstChild("vip3") local vip2 = char.Torso:FindFirstChild("vip2") local vip1 = char.Torso:FindFirstChild("vip1") if (vip1) then vip1:Remove() print ("del vip1") end if (vip2) then vip2:Remove() print ("del vip1") end if (vip3) then vip3:Remove() print ("del vip1") end creator.Parent = char.Torso end end) end)

    of     1