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

When part touched gui pops up not working?

here is the script - it is in a local script in the part that is being touched

local player = game.Players.LocalPlayer

script.Parent.Touched:Connect(function()
	player.PlayerGui.Win.Enabled = true
end)

4 answers

✓ Accepted answer

Normal script inside part:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:WaitForChild("Humanoid") then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        plr.PlayerGui.Win.Enabled = true
    end
end)

I used a normal script here because local scripts only work in ReplicatedStorage, StarterGui and StarterPlayer.

2 comments

0

yes that works :)

0

Could you please accept this as an answer then?

I am not sure if your way is correct, this is my way how to do it

script.Parent.Touched:Connect(function(Hit) -- The hit object called HIt
if Hit.Parent:FindFirstChild("Humanoid") then -- IT IS A PLAYER ! DO SOMETHING!
	local Player = Hit.Parent:GetPlayerFromCharacter(Hit.Parent)
	Player.PlayerGui.Win.Enabled = true
	end
end)

3 comments

0

Wrong.

0

Line 3 is wrong. Use mine(the one below this).

0

Welp fixed it lol

it didn't work. I changed the script to a normal script but still didn't work...

Keep it in the LocalScript. I'm assuming you renamed your ScreenGui to Win. You may want to try this method:

local Gui = game.StarterGui.Win.ImageButton -- If there's not an ImageButton, then change it to whatever it is inside of Win. ImageButton was just an example, but keep it if it's actually an ImageButton that a player is looking at.

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if Gui.Visible = false then
			Gui.Visible = true
		end
	end
end)

Hope this helps!

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