Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

TextButton GUI should close Frame, but it does nothing, why?

Asked by 4 years ago
Edited 4 years ago

Hello, Devs!

I was writing scripts and script didn't worked. So I was doing egg hatch system. I had no errors, but while editing TweenPosition to GUI that will show up when player will get closer to agg and will hide if player will click 'cancel' button then GUI will hide with TweenPosition. I have added an local script into 'cancel' button that should hide GUI when player will click 'cancel', but something didnt' worked.

CODE:

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.PlayerGui.Eggs.Egg1.Egg1:TweenPosition(
        UDim2.new(0.435,0,0, 300),
        Enum.EasingDirection.InOut,
        Enum.EasingStyle.Sine,
        2,
        true,
        nil
    )
end)

END OF THE CODE

Also I have added LocalScript into the ScreenGui, but this LocalScript worked. This second LocalScript was created like this: Script in part detecting Touched event. Code in this script:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        game.ReplicatedStorage.RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
    end
end)

And this worked. Sent signal to RemoteEvent and then LocalScript that shows GUI by TweenPosition worked. That was the working code in it:

game.ReplicatedStorage.EggPopup.OnClientEvent:Connect(function()
    if script.Parent.Egg1.Egg1.Position == UDim2.new(0.435, 0,0, 780) then
    game.Players.LocalPlayer.PlayerGui.Eggs.Egg1.Egg1:TweenPosition(
        UDim2.new(0.435,0,0, 300),
        Enum.EasingDirection.InOut,
        Enum.EasingStyle.Sine,
        2,
        true,
        nil
        )
        end
end)

This LocalScript was in the ScreenGui on explorer how I said before. Then when GUI is on screen our problem arrives. 'cancel' button dosen't work. LocalScript was in the 'cancel' button on explorer. Thanks in advice.

Answer this question