hi, it’s me again the last script from the last post didn’t work so I found this script and modified. But the problem is that its not FE compatible. my sword script (the one below) is supposed to damage the player but doesn’t. Any help
local debounce = false
local function onTouched(hit)
if (hit.Parent:findFirstChild("Humanoid")~= nil) and script.Parent.Swinging.Value == true then
if not debounce then
debounce = true
hit.Parent.Humanoid:TakeDamage(40)
wait(10)
debounce = false
end
end
end
script.Parent.Union.Touched:Connect(onTouched)
and again, I am sorry if a being too needy but I am a HUGE noob at scripting and any help with my taken thanks.
Clients cannot damage other humanoids, so the server needs to take care of that.
This may not be working in a server script because of your swinging value (which I don’t know anything about). Your code worked for me otherwise.
Usually when a classic sword relies on the Touched event it would use a server script in the blade/handle for detecting touch events and dealing damage, while a local script in the tool would handle user input like clicking their mouse to swing or lunge.
The script you posted should definitely be a server script, but like @imalex4 said if that script.Parent.Swinging.Value is being changed by the local script, the server script won’t detect the change. Removing that check might make the sword work.
But what we mean is that if a local script is changing that value, then the server script with the Touched event won’t recognize the change since from the server’s perspective that value will always be ‘false’
Well, I will show you a basic script which works for hit and damage on the server, and try to make something from it.
local Debounce = false
workspace.Baseplate.Touched:Connect(function(hit)
if Debounce == false and hit.Parent:FindFirstChild("Humanoid") then
Debounce = true
hit.Parent.Humanoid:TakeDamage(50)
wait(3)
Debounce = false
end
end)
Also remember this anything done on the client will only show for the client, for example if I delete a baseplate, it will only delete for me. Only things on the server replicate for everyone
Try changing your script to this and let us know if it works:
local debounce = false
local function onTouched(hit)
--if (hit.Parent:findFirstChild("Humanoid")~= nil) and script.Parent.Swinging.Value == true then
if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then
if not debounce then
debounce = true
hit.Parent.Humanoid:TakeDamage(40)
wait(10)
debounce = false
end
end
end
script.Parent.Union.Touched:Connect(onTouched)
That’s what we been saying. The reason is your executing it from a local script anything run on a local script will ONLY show for the player/Client. That;s why you have to do it from the server, so it replicates to everyone