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

Why is my script not finding a GUI in PlayerGui? Part 2...

This script that I made is supposed to tween a Frame in a GUI when you touch a brick, but I keep getting an error.

(This script works in studio, but not in game!)

function onTouched(m)
	local debounce = true
	local p = m.Parent:findFirstChild("Humanoid")
	if p ~= nil then
		if debounce == true then
			debounce = false
			p.WalkSpeed = 0
			local name = p.Parent.Name
			local player = game:GetService("Players"):WaitForChild(name)
				player.PlayerGui:WaitForChild("Teleport").Frame:TweenPosition
				(UDim2.new(0,0,0,0), "Out", "Linear", 1)
			wait(2)
			p.Torso.CFrame = script.Parent.b.CFrame
			wait(1)
				player.PlayerGui:WaitForChild("Teleport").Frame:TweenPosition
				(UDim2.new(0,0,-2,0), "Out", "Linear", 1)
			wait(0.1)
			debounce = true
			wait(1)
			p.WalkSpeed = 16
		end
	end
end
script.Parent.boi.Touched:connect(onTouched)

I asked this before and someone answered, but the script wouldn't have worked with the full script, so here it is...

1 comment

0

Use a LocalScript to handle guis

1 answer

You’re using lots of deprecated code.

On line 3, change findFirstChild to FindFirstChild

On line 4, remove the ~= nil part as it’s unimportant and only extends your if statement

On line 24, change connect to Connect

Another error is you’re trying to modify GUI from the server. I gave you a previous answer, just fit the FireClient() there somewhere in your script.

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