I’m making a garage system for a driving simulator, and one of the features is that an overlay tweens in when the player presses “F” to go into the garage.
I’ve got a BindableEvent that fires from a ModuleScript to a LocalScript.
-- ModuleScript (Some things have been taken out for simplification)
settings.FocusedOnGarage = false
function settings:ToggleGarageCamera(Player, Camera, GaragePart)
if settings.FocusedOnGarage == false then
game.ReplicatedStorage.Events.FireGarageOverlay:Fire(Player.PlayerGui.GarageOverlay.Frame)
settings.FocusedOnGarage = true
else
if settings.FocusedOnGarage then
game.ReplicatedStorage.Events.FireGarageOverlay:Fire(Player.PlayerGui.GarageOverlay.Frame)
settings.FocusedOnGarage = false
end
end
return settings.FocusedOnGarage
end
-- LocalScript (Some things have been taken out for simplification)
local Event = game.ReplicatedStorage.Events.FireGarageOverlay
Event.Event:Connect(function(instance)
local success, err = pcall(function()
if instance:IsA("Frame") then
if instance.Position == UDim2.new(0, 0, 0, 0) then
-- Tween the UI in one direction (in)
elseif not instance.Position == UDim2.new(0, 0, 0, 0) then
-- Tween the UI in the other direction (out)
end
end
end)
if success then
print("tweened")
else
if err then
error(tostring(err))
end
end
end)
The thing is, my console prints “tweened”, even though it hasn’t been tweened