gui = game:GetService("StarterGui")
script.Parent.MouseClick:Connect(function()
gui.ScreenGui.Frame:TweenPosition(UDim2.new(0, 0, 0, 0),'In','Quad',1)
end)
This is a LocalScript, and I'm wondering what is wrong. Am I missing something?
gui = game:GetService("StarterGui")
script.Parent.MouseClick:Connect(function()
gui.ScreenGui.Frame:TweenPosition(UDim2.new(0, 0, 0, 0),'In','Quad',1)
end)
This is a LocalScript, and I'm wondering what is wrong. Am I missing something?
What Vezious said is valid that you have to use player gui instead of starter gui but you also forget that the easing direction and the easing style are enum values, not strings. therefore, the correct local script code should be similar to:
local Player = game.Players.LocalPlayer
local Gui = Player.PlayerGui:FindFirstChild("ScreenGui")
script.Parent.MouseClick:Connect(function()
Gui.Frame:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,1)
end)
also, as you have this in a mouse click,if you want to make it open and close, I also encourage the setting of the override variable to true as if a player clicks the button again before the tween finishes playing, it doesn't seem "glitchy"
local open = false
local Player = game.Players.LocalPlayer
local Gui = Player.PlayerGui:FindFirstChild("ScreenGui")
script.Parent.MouseClick:Connect(function()
if not open then
Gui.Frame:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,1,true)
open = true
else
--tween to closed position
open = false
end
end)
The tweening styles can be written as a string...
Really? The only time i saw the EasingStyle written as a string was in a function and the string was for Enum.EasingStyle[s]
Still doesn't work. Idk why I'm having trouble, never had an issue before.
Also there are no errors in the output, which is what I kind of hate. Doesn't tell you what's going on. :(
Wait, I know the issue. It could be involving client server relations.
Can’t type an answer now but simply learn about RemoteEvents and use them for this function
i dont think REs are needed for tweening GUI elements in a local script
Wait, nvm, but if it’s a local script, it should be in the GUI. If he wants a part to show up he has to refer like game.Workspace.blah
yea, it does refer to the mouse click event, which is exclusive to click detectors
I don't really know how to use RemoteEvents, so...
It’s not RemoteEvents actually, but u have to relocate ur script to the GUI, and then change the reference to the detector
The problem is that you're Tweening the StarterGui one.
You need to get the player's clone of the GUI. It's found under Player.PlayerGui.
Therefore, your script should look like this:
local Player = game.Players.LocalPlayer
local Gui = Player.PlayerGui:FindFirstChild("ScreenGui")
script.Parent.MouseClick:Connect(function()
Gui.Frame:TweenPosition(UDim2.new(0,0,0,0),"In","Quad",1)
end)
For whatever reason, it still doesn't work. Idk whats going on
What's the error?
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
try printing some important aspects of the frame and gui, for example : whether the frame is visible, if the gui is enabled, if the script isnt disabled, and the size and position of the screen gui. Also, MouseClick is an event for click detectors, so what is script.Parent?
A click detector
so maybe have a script that fires a remote event that tweens the gui on the client