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

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

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.

3 comments

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.

0

That is very true.

0

Is your script a server script or a local script?

1 answer

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 :)

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