Player Gui script not working

this is a very generic question, apologies.

I looked for articles about this and I can’t find a solution.
So its pretty straightforward, I’m making a trigger box with a script to show gui and to hide it depending if you’re in the trigger box or not.
I get no errors but it seems to never call the onTouched function
I actually changed the function connecting from the easier way of doing it

script.Parent.Touched:Connect(function()

to the onTouched function way because I thought that might’ve done something, but it didn’t , so thats why the way of coding the ontouched function is weird in this script.


local fuseGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("Misc"):WaitForChild("Fuser")
local function resetFuseGui()
	fuseGui.Title.Text = "'element' Magic Plushie Fuser"
	fuseGui.PlushList.Text = "plush,plush,plush,plush"
	fuseGui.Fuse.Image = "http://www.roblox.com/asset/?id=8483123699"
	fuseGui.Visible = false
end
function onTouched(part) 
	print("success")
	resetFuseGui()
	fuseGui.Title.Text = "Neutral Magic Plushie Fuser"
	fuseGui.PlushList.Text = "White Winged, White Basic, Yellow WInged, Yellow Basic, Blue Winged, Blue Basic, Green Winged, Green Basic, Red Winged, Red Basic"
	fuseGui.Fuse.Image = "http://www.roblox.com/asset/?id=8483123699"
	fuseGui.Visible = true
	
end



function onTouchedEnded(part) 
	resetFuseGui()
end
script.Parent.Touched:connect(onTouched)
script.Parent.TouchedEnded:connect(onTouchedEnded)

this is a local script btw

the text and stuff is weird lol but don’t pay attention to that

The touched function isn’t firing because its in a localscript. You should try doing it in a server script and firing a remote event instead.

A LocalScript will only run Lua code if it is a descendant of one of the following objects:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts .
  • The ReplicatedFirst service
1 Like

Oh ok, but doesn’t the list say playerGui?

Also, I’m new to scripting lol, I’ve used remote events once so could you help me on how I could turn this code into server script compatible? Sorry for the inconvenience lol

where is the localscript? is it in a part in the workspace? because if it is then localscripts cant run in the workspace
For remote events read this RemoteEvent (roblox.com)
Edit: sorry I meant read this Remote Functions and Events (roblox.com)
If you still don’t understand something you can ask me

1 Like

I hate filtering enabled sometimes lol. I’ll read that, thanks!

ps: its in a trigger block in workspace, would there be a way to do this in screen gui? Only if its easier than remote events

thank you!

You could do it from screen gui just make a new localscript inside of StarterGui and replace

script.Parent.Touched:connect(onTouched)
script.Parent.TouchedEnded:connect(onTouchedEnded)

with workspace.PATH TO PART.touched:Connect
also you should capitalize Connect im pretty sure connect got deprecated
but learning remote events would help you a lot in the future so I think you should try doing it with remote events

1 Like

Is the script inside a Gui Button? If so, then replace .Touched into .MouseButton1Down and replace .TouchEnded into .MouseButton1Up

local fuseGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("Misc"):WaitForChild("Fuser")

local function resetFuseGui()
	fuseGui.Title.Text = "'element' Magic Plushie Fuser"
	fuseGui.PlushList.Text = "plush,plush,plush,plush"
	fuseGui.Fuse.Image = "http://www.roblox.com/asset/?id=8483123699"
	fuseGui.Visible = false
end

function onTouched(part) 
	print("success")
	resetFuseGui()
	fuseGui.Title.Text = "Neutral Magic Plushie Fuser"
	fuseGui.PlushList.Text = "White Winged, White Basic, Yellow WInged, Yellow Basic, Blue Winged, Blue Basic, Green Winged, Green Basic, Red Winged, Red Basic"
	fuseGui.Fuse.Image = "http://www.roblox.com/asset/?id=8483123699"
	fuseGui.Visible = true
end

function onTouchedEnded(part) 
	resetFuseGui()
end

script.Parent.MouseButton1Down:Connect(onTouched)
script.Parent.MouseButton1Up:Connect(onTouchedEnded)
1 Like