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

Can you help me check over this script? im using a tutorial and somethings not working right

I have no idea why its not working can anybody help me

game.Players.PlayerAdded:Connect(function(player)
	--
	--
	local inMenu = Instance.new("BoolValue")
	inMenu.Name = "InMenu"
	inMenu.Parent = player
end)

game.ReplicatedStorage.MenuPlay.OnServerEvent:Connect(function(player)
	if player:FindFirstChild("InMenu") then
		--Removes InMenu tag
		player.InMenu:Destroy()
	end
end)

1 comment

0

you firing the event somewhere?

2 answers

The code seems fine, is there a RemoteEvent named MenuPlay in the ReplicatedStorage? If not, you'll need to add that.

you need to put

game.ReplicatedStorage.MenuPlay.OnServerEvent:Connect(function(player)
    if player:FindFirstChild("InMenu") then
        --Removes InMenu tag
        player.InMenu:Destroy()
    end
end)

into the PlayerAdded function itself because the player is not defined code will look something like this:

game.Players.PlayerAdded:Connect(function(player)
    --
    --
    local inMenu = Instance.new("BoolValue")
    inMenu.Name = "InMenu"
    inMenu.Parent = player

	game.ReplicatedStorage.MenuPlay.OnServerEvent:Connect(function(player)
    		if player:FindFirstChild("InMenu") then
        		--Removes InMenu tag
        		player.InMenu:Destroy()
    		end
	end)
end)

1 comment

0

player is defined on the function that is fired by the event

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