I have projectiles that are constantly rotating and facing the player’s mouse, so what I did, was set the network owner of the projectile as the player, then in the player’s client I handle the rotation. After the player releases the key I shoot the projectile, and detect the collision on the server.
Server Script -
local vfx = Instance.new('Folder')
vfx.Name = plr.Name..' VFX'
vfx.Parent = game.Workspace.VFX
local table = {}
for i = 1, 3 do
local spear = folder['Ice Spear']:Clone()
table[#table + 1] = spear
local wc = Instance.new('WeldConstraint')
wc.Part0 = spear.Main
wc.Part1 = spear.Ice
wc.Parent = spear.Main
spear.Parent = vfx
for i, v in pairs(spear:GetChildren()) do
v.Size = Vector3.new(0, 0, 0)
v:SetNetworkOwner(plr)
end
local connection
connection = spear.Main.Touched:Connect(function(hit)
connection:Disconnect()
remote:FireAllClients(plr, set, skill..'2', spear.Main.Position)
spear:Destroy()
end)
end
remote:FireClient(plr, plr, set, skill, table)
Client Script -
local cfs = {CFrame.new(-5, 0, 0), CFrame.new(0, 5, 0), CFrame.new(5, 0, 0)}
local time = tick()
for i, v in pairs(x) do
v.Main.Anchored = true
local wc = Instance.new('WeldConstraint')
wc.Part0 = v.Main
wc.Part1 = v.Ice
wc.Parent = v.Main
v.Main.CFrame = hrp.CFrame * cfs[i]
TS:Create(v.Main, TweenInfo.new(.5), {
Size = folder['Ice Spear'].Main.Size;
}):Play()
coroutine.wrap(function()
wait(.5)
TS:Create(v.Ice, TweenInfo.new(.5), {
Size = folder['Ice Spear'].Ice.Size;
}):Play()
end)()
end
local connection
connection = RS.RenderStepped:Connect(function()
hrp.CFrame = CFrame.new(hrp.Position, mouse.Hit.Position)
for i, v in pairs(x) do
v.Main.CFrame = hrp.CFrame * cfs[i]
v.Main.CFrame = CFrame.new(v.Main.Position, mouse.Hit.Position) * CFrame.Angles(math.rad(-90), 0, 0)
end
if plr['Ice - C'].Value == false and (tick() - time) > .5 then
connection:Disconnect()
for i, v in pairs(x) do
TS:Create(v.Main, TweenInfo.new(1), {
CFrame = v.Main.CFrame * CFrame.new(0, 50, 0);
}):Play()
end
end
end)
Almost everything works fine, what doesn’t is the part where it detects the collision on the server, Touched doesn’t fire.
If y’all know how I can fix this, or can tell me a better way of doing it, I’d really appreciate it!