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

My touched event, only fires once for a player and not again. why?

My script is to run when the player touched a block. If they touch it, the script runs. But if the come and touch it again, the script doesn't run.

Script:

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		local level = player.leaderstats.Level
				
		if level.Value == 0 then
			player.PlayerGui.Levels.Level0Pc.Enabled = true
		end
	end
end)

If the player leaves the block and tries again the gui does not show.

1 comment

0

How are you hiding it?

1 answer

Do this in your playerGui script

local part = game.Workspace.Part
part.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		script.Parent.Parent.Parent.Enabled = true
	end
	script.Parent.MouseButton1Click:Connect(function()
		if script.Parent.Parent.Parent.Enabled == true then
		script.Parent.Parent.Parent.Enabled = false	
		end
	end)
end)

MOdify it with you player LeaderStast hope it helps. Unfortunatly I am not sure why it does not work

1 comment

0

I will try

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