I’m trying to use RaycastHitboxV4 in ServerScriptService but every example I’ve seen has been a script in the workspace.
Server Code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local signals = ReplicatedStorage.Signals
local remotes = signals.Remotes
local raycastHitbox = require(script.RaycastHitboxV4)
local playerCooldowns = {}
local humanoidsHit = {}
local cooldown = 0.75--will be changed because each tool has different cooldowns
local damage = 25
local Attack = {}
Attack.Init = function()
remotes.ToServer.OnServerEvent:Connect(function(player,signal,toolName)
local char = player.Character
local hum = char.Humanoid
if signal == "Trigger" then
local tool = char:FindFirstChild(toolName)
if tool then
if (playerCooldowns[player] and tick() - playerCooldowns[player] >= cooldown) or not playerCooldowns[player] then
playerCooldowns[player] = tick()
else
return
end
print("Successfully created")
local hitbox = raycastHitbox.new(tool.Hitbox)
local hitC = hitbox.OnHit:Connect(function(hit,humanoid)
print(hit,humanoid)
if humanoid == hum then return end
humanoid:TakeDamage(damage)
end)
print("Started")
hitbox:HitStart()
task.wait(cooldown)
hitbox:HitStop()
end
end
end)
end
return Attack
When I click and attempt to fire this event to the server nothing happens but started and successfully created both print so I think its something wrong with how I’m using RaycastHitbox.
I am also thinking of disconnecting the OnHit but I dont even know if its possible.