You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
make a virus creator
- What is the issue? Include screenshots / videos if possible!
when i put the function on remote event the server can’t receive my function and return void
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
yes
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Client
Use.MouseButton1Click:Connect(function()
local Func = GetFuncVirus(Character) -- GetFuncVirus returns the virus function
game.ReplicatedStorage.PlayVirus:FireServer(Func,Character)
end)
Server
game.ReplicatedStogare.PlayVirus.OnServerEvent:Connect(function(Player,Func,Character)
Func(Character) -- error: attemp to call a nil value
end)
note: i used print on client and returns the function not nil
here are the complete code:
Client
local Stages = script.Parent.Stages
local Kill = Stages.Kill
local Wait = Stages.Wait
local VirusDo = script.Parent.VirusDo
local Use = script.Parent.Use
local SpecialWait = Stages.SpecialWait
local Infect = Stages.Infect
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
function GetFuncVirus(Character)
return function()
for i,v in pairs(VirusDo:GetChildren()) do
if v:IsA("TextButton") then
if v.Name == "Kill" then
Character.Health = 0
elseif v.Name == "Wait" then
wait(1)
elseif v.Name == "SpecialWait" then
wait(v.Time.Value)
elseif v.Name == "Infect" then
local InfectRange = 10
local Closestcharacter,Closestdistance = nil,math.huge
for i,v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
local Distance = (v.PrimaryPart.Position-script.Parent.Position).Magnitude
if Distance <= InfectRange then
game.ReplicatedStorage.PlayVirus:FireServer(GetFuncVirus(v),v)
end
end
end
end
end
end
end
end
Kill.MouseButton1Click:Connect(function()
local KillClone = Kill:Clone()
KillClone.Parent = VirusDo
end)
Wait.MouseButton1Click:Connect(function()
local WaitClone = Wait:Clone()
WaitClone.Parent = VirusDo
end)
SpecialWait.MouseButton1Click:Connect(function()
local Clone = SpecialWait:Clone()
local Time = Instance.new("NumberValue")
Time.Name = "Time"
Time.Value = (tonumber(script.Parent.SpecialText.Text) or 1)
Time.Parent = Clone
Clone.Parent = VirusDo
end)
Infect.MouseButton1Click:Connect(function()
local Clone = Infect:Clone()
Clone.Parent = VirusDo
end)
Use.MouseButton1Click:Connect(function()
local Func = GetFuncVirus(Character)
print(Func)
game.ReplicatedStorage.PlayVirus:FireServer(Func,Character)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

