Why isnt this bindable event working?

ive been trying to fix this bindable event to work is there a reason its not working, it did fire it
i rechecked the name of it im not sure why it doesnt work, it prints out “works” but not “fired”

local damageEvent = game:GetService(“ReplicatedStorage”).Events:WaitForChild(“DamageEvent”)
local lastslashEvent = game:GetService(“ReplicatedStorage”).Events.LastSlash
local blockingevent = game:GetService(“ReplicatedStorage”).Events.PlayerBlocking
local slasheffect = game.ReplicatedStorage.VFX.SwordVfx.Slash.Hit
local slashhit = game.ReplicatedStorage.VFX.SwordVfx.SwordSlash

local TweenService = game:GetService(“TweenService”)

local function moveBackward(humanoid)
local startPosition = humanoid.RootPart.Position
local endPosition = startPosition - humanoid.RootPart.CFrame.lookVector * 0.5
local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad)

local tween = TweenService:Create(humanoid.RootPart, tweenInfo, {Position = endPosition})
tween:Play()

end

print(“works”)
damageEvent.Event:Connect(function(humanoid, damageAmount, humanoidAttacker)
print(“fired”)
local slasheffect1 = slasheffect:Clone()
slasheffect1.Parent = humanoid.Parent.HumanoidRootPart

    local slashhit1 = slashhit:Clone()
    slashhit1.Parent = humanoid.Parent.HumanoidRootPart
    slashhit1:Play()

    humanoid:TakeDamage(5)
humanoid.WalkSpeed = 2
moveBackward(humanoid)
wait(0.1)
slasheffect1:Destroy()
wait(0.5)
humanoid.WalkSpeed = 8

end)

1 Like

Please format code it’s hard to read when it isn’t.
The problem could be in the code firing the event.
It could be a timing issue, has this definitely run before attempting to fire?
It could be a parenting issue, bindables will only run in the same context (server to server).

1 Like

can a bindable not run from a local to a server?

No. You need to use a remote event.
Works the same way but the commands are slightly different such as
event.onServerEvent:Connect and event:FireServer. When firing from client it will also add a ‘player’ argument to the args, so you just need to remember if you’re sending multiple args.

ahh i had many problems woth using a remote event thats why i tried using a bindable event, i couldnt get the remote one to work.

You should be able to just swap it over and amend your listener connection to
damageEvent.OnServerEvent:Connect(function(player, humanoid, damageAmount, humanoidAttacker)
And the firing one to damageEvent:FireServer(humanoid, damage amount,humanoid attacker)
(Sorry about any typos.)

ill try this tommorow when im free and let you know how it goes

it fired the event for every player on the remote event i wanted it to fire for only thr local player

Ok. This is kind of a separate issue, but do you mean only the local player should see the effect or that every player ran the effect?

So the problem is after each slash it runs the event and it fires for every player in the game example normally it does 5 damage on each event but if theres more players it will do more damage for the humanoid, example 2 players will be 10 damage 3 would be 15 and so on because it fires it for every player including the local player that is slashing.

Ive been trying to fix it so that doesnt happen.

Ah ok, I think it is because a new event connection is being created every time you run the function moveBackward.
If you put the eventlistener outside the function it should work as you wanted.

Oh what do you mean outside isnt it outside already tho?

Sorry you’re right, the formatting threw me.

ahh yes sorry if its a bit messy

if its easier for you to understand i can let you in to see the code fully or send screenshots tommorow.

Send a DM tomorrow if it’s still a problem. I can’t see what the issue is at the moment.

yup sure ill send one as i get on studio

RemoteFunctions and RemoteEvents are to communicate between the client and server. If we’re talking about BindableEvents or BindableFunctions, then they would have the same authority as whichever (client or server) called it, same applies to Modules.

like what @Wigglyaa said, please format the code, if you don’t know, it’s three backticks (under the escape key)

like this:

```lua
-- put some code here
```

then it becomes this

-- put some code here

also please show the second script for the bindable

1 Like