In a model of a rig the rig is in workspace
Is sight inside of the rig? The problem is most likely the path of the Sight variable
Sight is inside the rig, so the script should work
If the script is inside of workspace, then it won’t work because local scripts don’t run in workspace
On the server, It also doesn’t work so i am completly clueless right now
Yea but it’s a LocalScript right? I am just assuming that because you are trying to send information to the Server. Where is the Script located at?
The serverScript is in the model, Same place as the local script
Local scripts don’t work in the workspace, so you might not want to do that. I can’t really tell what the issue is with the server one because we don’t know which parts of the rig you’re referring to or what you’re trying to accomplish, what is Sight? Could you provide screenshots?
is sight even a part? does it have CanTouch enabled?
also why dont you remove the :FireServer events that could be the potential cause why it’s not working
Yes it is a part with cantouch enabled
I have tried to remove them and i changed the script to only be a server script but it still doesn’t work
alright give me your code without the :FireServer()
I have moved the touched event to the server script it was firing to
local fire = script.Fire
fire = script.Parent.Humanoid.Animator:LoadAnimation(fire)
local MeshId = "rbxassetid://2837888103"
local D = game:GetService("Debris")
local Hit
local canShoot = false
local Sight = script.Parent.Sight
local SeeingTarget = false
function Shoot()
local bullet = script.Bullet:Clone()
bullet.Parent = workspace
bullet.Transparency = 0
bullet.Position = script.Parent["M4A1 Model"].BarrelCover.Attachment.WorldPosition
bullet.Orientation = Vector3.new(math.random(1, 360), math.random(1, 360))
bullet.AssemblyLinearVelocity = Vector3.new(10, 10, 2)
bullet.AssemblyLinearVelocity = Vector3.new(10, -10, 2)
D:AddItem(bullet, 5)
fire:Play()
wait(.1)
bullet.AssemblyLinearVelocity = Vector3.zero
task.wait(0.05)
local Part = script.Part:Clone()
game:GetService("Debris"):AddItem(Part, 10)
Part.Parent = workspace
Part.Transparency = 0
Part.Position = script.Parent["M4A1 Model"].BarrelCover.Attachment.WorldPosition
Part.Orientation = Vector3.new(0, 0, 0)
local Attachment = Instance.new("Attachment", Part) -- the attachment used in Linearvelocity
local LV = Instance.new("LinearVelocity", Attachment) -- creating the linear velocity
LV.MaxForce = math.huge -- no need to worry about this
LV.VectorVelocity = script.Parent.HumanoidRootPart.CFrame.lookVector * 100 -- change 100 with how fast you want the projectile to go
LV.Attachment0 = Attachment-- setting the attachment
script.Part.Script:Clone().Parent = Part
task.wait(.2)
end
Sight.Touched:Connect(function(Part)
seeingTarget = true
end)
Sight.TouchEnded:Connect(function()
seeingTarget = false
end)
while SeeingTarget == true do
Shoot()
end
you should use .Changed functions.
while SeeingTarget == true do
Shoot()
end
this will not always detect if SeeingTarget is true
It gives an error
17:32:25.801 Workspace.Rig.Script:50: attempt to index boolean with ‘Changed’ - Server - Script:50
i realized one thing
while SeeingTarget == true do
Shoot()
end
please do not do this unless you want your game to crash. this will fire Shoot() endlessly without a single rest.
and consider changing SeeingTarget into a BoolValue so .Changed works, and don’t use while true loops unless you know what you’re doing.
If you look in the script at the top,SeeingTarget is a boolean it is set to false
local SeeingTarget = false
i am talking about a game object not a variable. BoolValue has the same functions as Boolean, but BoolValue is an actual object.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.