Im working on a skill but I have a problem with it, hence why I am here. Im trying to make a model that is welded to the PrimaryPart as the guns of this skill. The issue is that I need the guns to look at the mouse actively until the guns are fired. But there is a issue, even though i am using SetNetworkOwner (I give the player ownership to the PrimaryPart), when I set the CFrame.LookAt of the primary part on the client, despite it having network ownership the part is not being affected at all.
Example:
Owner of the part:
Spectator:
If this will help, heres my script so far.
SERVER:
local chr = player.Character
local guntable = {}
player.Character:SetAttribute("Charge",true)
task.spawn(function()
task.wait(6)
-- player.Character:SetAttribute("Charge",false)
end)
for i = 1,5 do
local thing = i/5
local gun = game.ReplicatedStorage.Gun:Clone()
gun.Parent = workspace
gun:PivotTo(chr.HumanoidRootPart.CFrame * CFrame.new(math.random(-6,6),math.random(3,6),0))
gun.MainPart.Anchored = false
gun.PrimaryPart:SetNetworkOwner(nil)
gun.PrimaryPart:SetNetworkOwner(player)
gun.MainPart.Anchored = true
table.insert(guntable,gun)
task.spawn(function()
task.wait(4+thing)
if i == 5 then
--player.Character:SetAttribute("Charge",false)
end
print("lo")
-- game:GetService("TweenService"):Create(gun.PrimaryPart,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{Position = gun.PrimaryPart.CFrame.LookVector * -10 + gun.PrimaryPart.Position}):Play()
end)
end
task.wait(3)
remot:InvokeClient(player,player,script.Name,"R",guntable) -- in case of confusion, this line sends the client the player value, the script name (for client interaction, the server and the client skillset has the same name.), the key that was pressed, and the guntable which has all the gun models.
CLIENT:
local mouse:Mouse = player:GetMouse()
local gun:Model = params
local chr = player.Character
for i,v in pairs(gun) do
v.PrimaryPart.Attachment.ParticleEmitter:Emit(1)
v.PrimaryPart.Attachment.ParticleEmitter2.Enabled = false
v.PrimaryPart.Attachment.ParticleEmitter3.Enabled = false
v.PrimaryPart.Attachment.ParticleEmitter2.Enabled = true
v.PrimaryPart.Attachment.ParticleEmitter3.Enabled = true
end
while chr:GetAttribute("Charge") == true do task.wait()
for i,v in pairs(gun) do
v.PrimaryPart.CFrame = CFrame.lookAt(v.PrimaryPart.Position,mouse.Hit.Position)
end
end
i really need help on this, any advice would be helpful!