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

I'm trying to make a script that deletes a certain gui but it wont work how do I fix this?

Asked by
v_anze 0
4 years ago

local plr = game.Players.LocalPlayer game.Players.PlayerAdded:Connect(function(plr) if plr.Name == "V_anze" then print("ok") if not plr.Name == "V_anze" then game.Players.LocalPlayer.PlayerGui.Cmdr:Destroy() end end end)

I'm confused on why it's not working.

I'm pretty new with scripting.

0
First off, please format your code correctly, it's kinda hard to see. Also why are you using player added and local player in the same script. Local Player is for local scripts, player added for server scripts, you should never put both of those in the same script. JeffTheEpicRobloxian 258 — 4y
0
That is very true. iivSnooxy 248 — 4y
0
Is your script a server script or a local script? notfenv 171 — 4y

1 answer

Log in to vote
1
Answered by
nievadev 112
4 years ago

Your code has logic issues. No worries, here is a fix.

local plr = game.Players.LocalPlayer

game.Players.PlayerAdded:Connect(
    function(plr)
        if plr.Name == "V_anze" then
            print("ok")
        else
            game.Players.LocalPlayer.PlayerGui.Cmdr:Destroy()
        end
    end
)

Remember to accept the answer if is it helpful for you! I'm glad to help :)

Ad

Answer this question