I’m having an issue with my GUI that makes it not move when the BindableEvent is being fired. It’s in a localscript. Other functions in the exact same script use the same code, and it still tweens when using those functions so I’m not too sure as to what’s going on.
function win(winnername)
warn("Function win") -- It's being printed.
local winf
if not winf == true then
winf = true
wait()
local newpos = UDim2.new(0.5, 0, 0.5, 0)
local oldpos = UDim2.new(0.5, 0, 2, 0)
script.Parent.Parent:TweenPosition(newpos, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
wait(.1)
local playerUsername = game.Players.LocalPlayer.Name
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TypeWriter = require(ReplicatedStorage:WaitForChild("TypeWriter"))
TypeWriter.typeWrite(script.Parent, "Game Over! "..winnername.." has won the game.")
wait(2)
script.Parent.Parent:TweenPosition(oldpos, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
script.Parent.Text = "Waiting for map..."
else
return
end
end
Sorry, late reply.
Yeah, I used :Connect. I’ve added how it’s been fired below:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local newPlayerEvent = ReplicatedStorage:WaitForChild("EliminatedPlayer")
local gameEnd = game.ReplicatedStorage.WinnerPopup
gameEnd.OnClientEvent:Connect(win)
Does the warning output? The only thing that seems off about this code so far is the winf variable. I think the code should have local winf = false outside the function.
Change if not winf == true then to if not winf then. Also, try having local winf = false outside the function since it’s currently not accessible outside the function which will most likely cause it to not work as intended.
Possibly, I’ll try switching that around and let you know.
Edit: There doesn’t seem to be an issue, I’ll add another function that does work, it’s basically the same thing. I don’t see any differences between them, but if you want to look, maybe you’ll have a better eye than me haha.
Script:
function textadd(mapName)
local newpos = UDim2.new(0.5, 0, 0.5, 0)
local oldpos = UDim2.new(0.5, 0, 2, 0)
script.Parent.Text = "Loading Map..."
script.Parent.Parent:TweenPosition(newpos, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
wait(.1)
local map = game.Workspace.Maps:FindFirstChildOfClass("Model")
wait(map:WaitForChild("Settings"))
local playerUsername = game.Players.LocalPlayer.Name
-- Roblox services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Require module
local TypeWriter = require(ReplicatedStorage:WaitForChild("TypeWriter"))
TypeWriter.typeWrite(script.Parent, mapName.Settings.MapName.Value.." by "..mapName.Settings.Creator.Value.." has been chosen.")
wait(2)
script.Parent.Parent:TweenPosition(oldpos, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
script.Parent.Text = "Waiting for map..."
end
Not sure why there’s so much red, sorry about that.
Yeah, they’re in the correct position. I ended up copying and pasting another function that did essentially the same thing to no avail, so I think something else is doing it. The game has a lot of loading and resetting the character is doing it.
Yeah, JackOfAllTrades101 said to just declare it as false outside of the function. I think it was the resetting and stuff that caused it not to work, as I mentioned before.
function win(winnername)
warn("Function win")
if not winf then
winf = true
local newpos = UDim2.new(0.5, 0, 0.5, 0)
local oldpos = UDim2.new(0.5, 0, 2, 0)
script.Parent.Parent:TweenPosition(newpos, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
wait(.1)
-- Roblox services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Require module
local TypeWriter = require(ReplicatedStorage:WaitForChild("TypeWriter"))
TypeWriter.typeWrite(script.Parent, "Game over! "..winnername[1].." has won the game!")
wait(2)
script.Parent.Parent:TweenPosition(oldpos, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
script.Parent.Text = "Waiting for map..."
else
return
end
end
game.Workspace.Maps.ChildAdded:Connect(textadd)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local newPlayerEvent = ReplicatedStorage:WaitForChild("EliminatedPlayer")
local gameEnd = game.ReplicatedStorage.WinnerPopup
gameEnd.OnClientEvent:Connect(win)
newPlayerEvent.OnClientEvent:Connect(plrrmv)
winf = false
I think I’m getting onto something though as it’s tweening properly, it’s just the text that isn’t displaying.
Yeah, I got it to work. The issue was that I was doing Player:LoadCharacter() before the GUI tweened, causing the issue. Thank you, as well as @JackOfAllTrades101 for helping! It’s greatly appreciated.