I’m working on a skill that spawns a small pillar of ice in front of the users. I’m cloning the model from ReplicatedStorage and immediately parenting it to workspace, underneat the terrain and in front of the player. That’s because I immediately fire a remote to all clients, to animate the pillar so it looks like it’s “raising”/“growing” from the ground. I’m using TweenService to do it and doing it on the client for optimization’s sake.
Unfortunately, when I pass the arguments to the client (ice pillar model, player’s HRP and the final CFrame that the ice model must be tweened to), the pillar model results nil\non-existing and I have no idea why because it makes no sense, since the skill worked in the past but not anymore, after I resumed working on it after a few weeks.
Here is the relevant code:
SERVER CODE - clones pillar model and places it in front of the player, slightly under the terrain and calculates the final CFrame for the client to tween to.
function spell:Cast(plr,result)
local char = plr.Character or plr.CharacterAdded:Wait()
local HRP = char:FindFirstChild("HumanoidRootPart")
local diskModel : Model = vfxModule:FindFirstChild("IceDisks")
local iceDisks : Model = diskModel:Clone()
local finalCF = CFrame.new(HRP.Position + HRP.CFrame.LookVector * 3 - Vector3.new(0,3.5,0)) * CFrame.Angles(0,0,math.rad(90))
iceDisks:PivotTo(CFrame.new(HRP.Position + HRP.CFrame.LookVector * 3 - Vector3.new(0,10,0)) * CFrame.Angles(0,0,math.rad(90)))
iceDisks.Parent = game:GetService("ReplicatedStorage") --tried both workspace and RS, both result nil on the client.
print(iceDisks) --returns the model on the server, as expected.
Service.Remotes.vfxReplicator:FireAllClients(vfxModule,"risePillar",iceDisks,HRP,finalCF)
--i use a client replicator, as seen here.
end
CLIENT VFX PART - it’s a module script parented to ReplicatedStorage.
actions["risePillar"] = function(var) --water form
print(var) --all values sent from the server exist, except for iceDisks, which results "void"
local iceDisks : Model = var[2] --returns void\nil for some reason
local HRP = var[3]
local finalCF = var[4]
iceDisks.Parent = workspace:WaitForChild("Bullets") --errors, saying i'm trying to parent nil to workspace.Bullets.
iceDisks.PrimaryPart = iceDisks:FindFirstChild("Base") --also couldn't find the parts.
local CFValue = Instance.new("CFrameValue")
CFValue.Value = iceDisks.PrimaryPart.CFrame
CFValue.Parent = iceDisks
--tweening stuff.
local riseTween = Service.TS:Create(CFValue,TweenInfo.new(1),{Value = finalCF})
CFValue:GetPropertyChangedSignal("Value"):Connect(function()
iceDisks:PivotTo(CFValue.Value)
end)
riseTween:Play()
riseTween.Completed:Connect(function()
CFValue:Destroy()
end)
end
--What the VFX module returns
return function(...)
local var = {...} --variadic function
local action = var[1] --in this case "risePillar"
actions[action](var)
end
VFX REPLICATOR SCRIPT - adding it just in case, but I know this isn’t the problem cuz the other skills work just fine.
local Service = require(game:GetService("ReplicatedStorage"):WaitForChild("Modules"):WaitForChild("Services"))
Service.Remotes:WaitForChild("vfxReplicator").OnClientEvent:Connect(function(Module, ...)
local moduleF = require(Module)
moduleF(...)
end)
In the scripts you’ll find some comments explaining what the code does; also here is a screenshot of the console: