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.
This script looks extremely messy:
First off When setting core it should be done in StarterPlayerScripts
.
Secondly a few error you made in your script:
script.Parent.MouseButton1Click:Connect(function()
- Don't space out function()
- Use :Connect not :connect because :connect is deprecated
Next:
Parent
notparent
lastly:
- Give your tween a time
So your final script should look like:
script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent:TweenPosition(UDim2.new(0, 0, -1, 0),"In","Quad", 1) -- 1 second tween wait(1) -- no space script.Parent.Parent.Parent:Destroy() pcall(function() local starterGui = game:GetService('StarterGui') starterGui:SetCore("TopbarEnabled", true) end) end)
Hoped this helped if you get any errors make sure to comment and tell me if it doesn't work debug by using print()
. Also, make sure this is a local script.
Best of luck
I've fixed a bit your code.
script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent:TweenPosition(UDim2.new(0, 0, -1, 0),'In','Quad',1) wait(1) script.Parent.Parent.Parent:Destroy() pcall(function() local StarterGui = game:GetService('StarterGui') StarterGui:SetCore("TopbarEnabled", true) end) end)
Make sure it's in a LocalScript
You need use Wait time in TweenPosition.
Locked by Leamir, brokenVectors, and User#19524
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?