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
Use a LocalScript to handle guis