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

how to make a gui visible only to player who touched a brick?

so im making a text label that should be only visible for player who touched a brick. this is what i have done so far:

script for the brick:

local part = script.Parent
part.Touched:Connect(function(hit)
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum then
		local plr = game.Players:FindFirstChild(hum.Parent.Name)
		if plr.GreenDirt.Value == false then
			hum.WalkSpeed = 0
			hum.JumpPower = 0
			plr.GreenDirt.Value = true
			script.Text.Disabled = true
		end
	end
end)

and heres the script that is supposed to show the guis:

local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("TFlaniganDialogue")
wait(1)
gui.d1.Visible = true

is there something i did wrong? i would appreciate any help.

1 comment

0

Are the script that's shows up the GUI was LocalScript, or there any errors occurred there?

2 answers

✓ Accepted answer

Do it all in 1 script (Normal script inside the brick.)

local part = script.Parent
	part.Touched:Connect(function(hit)
	    local hum = hit.Parent:FindFirstChild("Humanoid")
	    if hum then
	        local plr = game.Players:FindFirstChild(hum.Parent.Name)
	        if plr.GreenDirt.Value == false then
	            hum.WalkSpeed = 0
	            hum.JumpPower = 0
	            plr.GreenDirt.Value = true
	            script.Text.Disabled = true
                     local gui = plr:FindFirstChild("PlayerGui")
                    gui:WaitForChild("TFlaniganDialogue").d1.Visible = true
	        end
	    end
	end)

Also, the localScript seems to normally just turn on the Gui after 1 second. Remove the localscript, add this in the part (NormalScript)

If this did work, please mark it as the correct answer, I'm trying to get a reputation build-up here :)

2 comments

0

Uhh this is NOT a good idea! FilteringEnabled is a thing and this Shouldn't have worked! Please check that Experimental Mode is Disabled. You are trying to get a Gui in the player Trough a ServerScript. Which should be accessed in a LocalScript

0

No, it still works, I've tried

I think you can do some adjustments

local part = script.Parent
part.Touched:Connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
    if hum then
        local plr = game.Players:FindFirstChild(hum.Parent.Name)
        if plr.GreenDirt.Value == false then
            hum.WalkSpeed = 0
            hum.JumpPower = 0
            plr.GreenDirt.Value = true
            script.Text.Disabled = true
	    game:GetService("StarterGui").TFlaniganDialogue.Visible  = true
        end
    end
end)

Maybe this will work, if it was not working, ask me below the comments!

If this is working for you, please mark this as the answer- I don't like to say, but it helps a lot, thanks!

4 comments

0

Wow, I never had posted my answer so quick...

0

not rly

0

i mean it doesnt work

0

Oh... I've already try my best because I never answered this type of question lol

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