roblox keeps saying this:
but the workspace show this:
my code is:
please help me fix this.
Rename it with another name and use :FindFirstChild()
If it’s showing that then I believe it’s a client to server issue, so we need more information if the workspace is showing it from client view or server view.
Example:
the workspace was showing the client view. The server view doesn’t have the attachment.
server view:
how do I make it so that the server DOES see it?
That removed the error but the attachment still doesn’t work.
Please help me with this!!! This is so annoying!
post the code in a code block and I will setup so if there isn’t attachment it will still work
also you are just trying to add a beam into the character? nm i see your trying to simulate a laser shot to the player
alr
script.Parent.Fire.OnServerEvent:Connect(function(player,mousePos)
local raycastParams = RaycastParams.new()
--raycastParams.FilterDescendantsInstances = (player.Character)
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(script.Parent.Muzzle.Position,(mousePos - script.Parent.Muzzle.Position)*300,raycastParams)
if raycastResult then
local hitPart = raycastResult.Instance
local model = hitPart:FindFirstAncestorOfClass("Model")
if model then
if model:FindFirstChild("Humanoid") then
script.Parent["laser gun sound"]:Play()
script.Parent.Beam1.Attachment1 = model.Torso:FindFirstChild("BeamAttach")
script.Parent.Beam2.Attachment1 = model.Torso:FindFirstChild("BeamAttach")
model.Humanoid.Health -= 100
wait(.2)
script.Parent.Beam1.Attachment1 = nil
script.Parent.Beam2.Attachment1 = nil
end
end
end
end)
ok maybe try this it will try to find the attachement if it can’t it will create a new one and setup with the right name both beams in your code use same attach so thats how i left it – you can remove comments just added to try to help ya on the code
script.Parent.Fire.OnServerEvent:Connect(function(player,mousePos)
local raycastParams = RaycastParams.new()
--raycastParams.FilterDescendantsInstances = (player.Character)
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(script.Parent.Muzzle.Position,(mousePos - script.Parent.Muzzle.Position)*300,raycastParams)
if raycastResult then
local hitPart = raycastResult.Instance
local model = hitPart:FindFirstAncestorOfClass("Model")
if model then
if model:FindFirstChild("Humanoid") then
script.Parent["laser gun sound"]:Play()
-- below trys to find the attachemnt if it cant it will create a new one and name BeamAttach1
local BeamAttach1 = model.Torso:FindFirstChild("BeamAttach1") or Instance.new('Attachment', model.Torso)
BeamAttach1.Name = 'BeamAttach1' -- name it if it was created
-- if you need position offset or something set it here
script.Parent.Beam1.Attachment1 = BeamAttach1 -- set
script.Parent.Beam2.Attachment1 = BeamAttach1 -- if you are using the same attachement for them just do this else setup like above
model.Humanoid.Health -= 100
wait(.2) -- this may need to be longer to see beam render
script.Parent.Beam1.Attachment1 = nil
script.Parent.Beam2.Attachment1 = nil
end
end
end
end)