How to send non-replicated objects in remote events

Hello! This is my first topic so excuse me if it’s bad. In this tutorial, i’ll show you how to send non-replicated objects in remote events, like functions, tween infos, etc. this example will be with a tween info

So first, create a module script in replicated storage called “TweenInfos” or something like that, and type this:

local tween_infos = {}

return tween_infos

we will store our tween infos inside this module.

Now from here, we need to add the tween infos inside this tween_infos table

storing the infos inside the module:

local tween_infos = {
	["TWEENINFOIDHERE"] = TweenInfo.new(2) -- tweeninfo here
}

return tween_infos

next, we will send the id of the tween info to the client, which will then get the tween info and play the tween!
local script:

local replicated_storage = game:GetService("ReplicatedStorage")
local tween_service = game:GetService("TweenService")
local tween_remote = replicated_storage:WaitForChild("TweenEvent")
local tween_infos = require(replicated_storage:WaitForChild("TweenInfos"))
tween_remote.OnClientEvent:Connect(function(object:Instance, info_id, goals)
	local success, info = pcall(function() -- do this so the script wont break if the info id is invalid
		return tween_infos[info_id]
	end)
	if success and info then
		tween_service:Create(object, info, goals):Play() -- finally, play the tween!
	else
		warn(string.format("could not found tween info with id of %q", info_id)) -- if the info isn't found, we'll add a warning to the output so we can debug
	end
end)

this is our server script

local replicated_storage = game:GetService("ReplicatedStorage")
local infos = require(replicated_storage:WaitForChild("TweenInfos"))
local tween_remote = replicated_storage:WaitForChild("TweenEvent")
local part = workspace.Part
local info_id = "ColorTween"
local goals = {
	Color = Color3.fromRGB(75, 93, 255) --- pastel purple
}
task.wait(2) -- so we can see the tween
tween_remote:FireAllClients(part, info_id, goals)

there we go. hope this helps :slight_smile:

the final result is really nice

Hope this helps. If u have any questions then feel free to ask :slight_smile:

6 Likes

If I want to make it a fireball and get the player killed when touched, do I handle this in the client or server?

Sad that Roblox doesn’t allow the sending of TweenInfos or RaycastResults. It’s unfortunately been this way for a long time.

Anyways, thanks for the resource. :slight_smile:

Also, you probably don’t have to use pcall, you can just check if it’s nil or not. Doing a nil check over a pcall is probably faster.

oh sorry, i didn’t get any notifications about this.

I recommend via server. An exploiter can easily forge this.

If I do it on server then it would never fire because the client moves the part

yeah i wish you could send those. Which sux

eh, personal preference. I prefer pcall just to be extra safe.

1 Like

well i dont know how the fireball is handled. So i was just giving my advice from the vague information i was given.

1 Like