I was mainly confused about what kind of sanity check to make, this fits nicely, thank you!
For anyone trying to do the same in the future
Another issue I faced was the client that played the tween having the server tween replicated back, causing the property to act weird, but I managed to fix it with this local script:
local tweenService = game:GetService("TweenService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local replicateServerTween = replicatedStorage.remoteEvents.replicateServerTween
replicateServerTween.OnClientEvent:Connect(function(instance, tweenInfoTable, propertyTable)
tweenService:Create(
instance,
TweenInfo.new(table.unpack(tweenInfoTable)),
propertyTable
):Play()
end)
Then on the server:
local replicateServerTween = replicatedStorage.remoteEvents.replicateServerTween
local function fireAllClientsExcept(remoteEvent, data, exception)
for _, player in players:GetPlayers() do
if player ~= exception then
remoteEvent:FireClient(player, table.unpack(data))
end
end
end
local validTweensData = {
x = {{.25}, {Color = Color3.fromRGB(0, 0, 255)}},
y = {{.4}, {Color = Color3.fromRGB(255, 0, 0}}
}
replicateTween.OnServerEvent:Connect(function(player, instance, tweenType)
fireAllClientsExcept(
replicateServerTween,
{instance, table.unpack(validTweensData[tweenType])},
player
)
end)
Then just call fireServer on the “replicateTween” remote event from any client wit a tween type and it will replicate to all other clients.
Of course, the client can ask for any of the “valid” tween whenever since there are no sanity checks for this, you might want to adapt that.
I’m not worried since the tweens I’m replicating like that are purely visuals, colors, etc., and in my project, it’s nothing that provides any advantage/breaks something if exploited. (that’s also why I didn’t want to do it on the server, delays in visual effects are terrible)
Again, thank you @JayzYeah32, you’re very kind!