local gun = script.Parent
local gun_sound = script.Parent.Handle["Gun Shot"]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild('ShotEvent')
gun.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
remoteEvent:FireServer(script.Parent.Handle.Position, mouse.Hit.p)
gun_sound:Play()
end)
end)
Try using :WaitForChild(‘Handle’)
Still does not work? for some odd reason
Does it give an infinite yield warning?
no it does not give that type of warning
Could you show how you’re implementing the waitforchild?
Hmm. Does it give any other type of error? Could you show a screenshot of your hierarchy?
no other errors
Hmm, weird.
It’s weird how the error in your first reply shows that the tool is still in the backpack on equip.
Also, in your screenshot, you’re using a . instead of a : on :WaitForChild(). Try changing it to a colon and see if that works.
does not work roblos moment
i had this problem before but i forgot how to fix it
Do you have anything else named “Tool” in the backpack?
No i do not have anything else named “Tool” in the backpack.
On one of your lines of code it says:
gun.WaitForChild()
when it should be
gun:WaitForChild()
ik i have already fixed that earlier
local gun = script.Parent
local gun_sound = gun:WaitForChild("Handle"):WaitForChild("Gun Shot")
print(script.Parent.Name)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild('ShotEvent')
gun.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
remoteEvent:FireServer(script.Parent.Handle.Position, mouse.Hit.p)
gun_sound:Play()
end)
end)
Try this perhaps?
The script runs before the handle is even loaded in, to fix this you do-
local gun = script.Parent
local handle = gun:WaitForChild("Handle")
local gun_sound = handle:WaitForChild("Gun Shot")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild('ShotEvent')
gun.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
remoteEvent:FireServer(script.Parent.Handle.Position, mouse.Hit.p)
gun_sound:Play()
end)