I have made myself a script that when clicked will animate the GUI off of the players screen and then a second after clicking destroy the script. When testing this out using the Studio it works perfectly and smooth however when I load the game in the Roblox Player or create a local server in the Studio the script does not function. The script is as follows:
script.Parent.MouseButton1Click:connect (function()
script.Parent.parent:TweenPosition(UDim2.new(0, 0, -1, 0),"In","Quart")
wait (1)
script.parent.parent.parent:Destroy()
pcall(function()
local starterGui = game:GetService('StarterGui')
starterGui:SetCore("TopbarEnabled", true)
end)
end)
When the player clicks the button (which is the parent of the script) the GUI moves off the display, destroys and then the top bar becomes enabled (which is disabled when you first join the game).
EDIT: This question has been answered. Thanks everyone for the input.

1 comment
Thank you both. I have added it into a localscript and it is now working.