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

StarterGui won't enable after touching a part?

Hi, I'm AswormeDorijan111 i need help. I'm good graphics developer but I don't know scripting a lot... So can you please help me how to StarterGui GUI Show when I touch a part. Please please help. :)

script.Parent.Touched:connect(function(hit)
game.StarterGui.Buy1.Enabled = true
wait(300)
game.StarterGui.Buy1.Enabled = false
end)

1 answer

✓ Accepted answer

Hello, your problem is that you're not detecting when a certain player is stepping over a part and you're accessing the StarterGui instead of the player's PlayerGui.

Here's the correct code. Put this in a script inside of your part.

local Players = game:GetService("Players")
local debounce = false --Prevent a ton of hit detections at once.

local function onTouched(hit)
	if hit.Parent:FindFirstChild("Humanoid") then --Checks if a humanoid hit.
		if not debounce then
			debounce = true
			local chr = hit.Parent
			local plr = Players:GetPlayerFromCharacter(chr)
			if plr then --Checks if it was a player. 
				if plr.PlayerGui:FindFirstChild("Buy1") then --Makes sure the player has the right gui.
					if plr.PlayerGui.Buy1.Enabled == false then
						plr.PlayerGui.Buy1.Enabled = true
						wait(3)
						plr.PlayerGui.Buy1.Enabled = false
					end
				end
			end
		end
		debounce = false
	end
end

script.Parent.Touched:connect(onTouched)

Hope this is what you wanted if it isn't tell me.

2 comments

0

Man thanks you a lot you helped me a lot thanks you thanks you so muchhh :)

0

Make sure to accept my answer. : ) Happy to help.

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