I wanna make a sword with RemoteEvent that damages people when touched.
Everything works perfectly on the LocalScript but not in the Script and i couldn’t find any other solutions so i asked it here.
This is the code i wrote
Ignore the --(texthere) things
LocalScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
script.Parent.Handle.Touched:Connect(function(hit)
--local block = hit.Parent.Katana.Block
if slice.IsPlaying then
if script.Parent.Value.Value == 0 then
-- if block.Value == 0 then
print("works")
remoteEvent:FireServer(print("serverfired"))
script.Parent.Value.Value = 1
--elseif block.Value == 1 then
-- hit.Parent:FindFirstChild("Humanoid"):TakeDamage(0)
script.Parent.Value.Value = 1
end
end
end)
and this is the Script in ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
function onTouched(hit)
print("counted")
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(15)
end
remoteEvent.OnServerEvent:Connect(onTouched())
Any solutions please?