I made a script that does damage on hit and I made it two different scripts. One makes an event and all of the hitbox creation, along with animation in the future, and the other does the damage. But when I made the other script, it kept giving me =
21:00:05.939 - Infinite yield possible on 'ReplicatedStorage:WaitForChild("BAttack")'
I know what it means, but i'm not sure why its giving me this. My print BAttack is working, but the damage is not.
Server Script in Starter Pack
-Doesn't work
local event = game.ReplicatedStorage:WaitForChild("BAttack") or game.ReplicatedStorage.BAttack
event.OnServerEvent:Connect(function(player)
print("adsljkaa")
if player then
local humanoid = player.Parent.FindFirstChild("Humanoid")
humanoid:TakeDamage(6)
end
end)
Local Script in Starter Pack
-Does work
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
--local r = char.RightShoulder
local mouse = player:GetMouse()
local sword = char:WaitForChild("BSword") or char.BSword
local event = Instance.new("RemoteEvent", game.ReplicatedStorage) or game.ReplicatedStorage.BAttack
event.Name = "BAttack"
mouse.Button1Down:Connect(function()
--the hitbox
print("okok")
local hit = Instance.new("Part", workspace)
hit.Color = Color3.new(100, 0, 0)
hit.CFrame = sword.CFrame:ToWorldSpace(CFrame.new(0,0,3))
hit.Anchored = true
hit.CanCollide = false
hit.Touched:Connect(function(h)
event:FireServer(h)
print(event.Name)
end)
wait(.5)
hit:Destroy()
end)
Thanks for looking!

1 comment
I think having a server script in starter pack is not a good idea...