Extremely weird OnClientEvent behavior

So to cut right to the point, I am using an OnClientEvent to display a message to players

That works all well and good but, the weirdest thing is as soon as I add either a

task.wait()

or a Tween Completed function after the Tween:Play() the code just seems to stop abruptly and nothing else after will execute…

Here is the code, that’s all it is. I have no idea why it’s not excuting past tween:Play() when I do what I mentioned above

FunnyMessage.OnClientEvent:Connect(function(player)
   local newMessage : TextLabel = FunnyMessageHolder.Sample.FunnyMessage:Clone()
   newMessage.Text = player.Name.." tried to swim in lava"
   newMessage.Parent = FunnyMessageHolder 
   local tween = TweenService:Create(newMessage, FunnyMessageTweenInfo,{
      TextTransparency = 0,
      BackgroundTransparency = .7
   })
   tween:Play()
end)

What I have tried :
I tried using a Bindable Event which is fired after the Tween:Play() but that didnt
work
I tried restarting my studio, that didnt work
I tried making a new RemoteEvent because maybe the one I was using was bugged? (idk) and that also didnt work either
I even tried putting it on seperate threads using corutiines and task.spawn and NOTHING worked…

1 Like

When you do tween:Play() or task.wait(), have you tried putting a print after it? I see nothing which would cause the code to stop executing.

1 Like

I know right this is exaxctly what I am baffled about, I put a print statement after and it still didnt print

If you replace

with

task.wait(1)
print("Effect")

Does it still not print?

Yeah, I just tried it again and it doesnt print out absolutely a thing

This is the server script if it helps but like what even is there to look at

FunnyMessage.OnServerEvent:Connect(function(player)
   FunnyMessage:FireAllClients(player)
end)

If you add a print at the start of the OnClientEvent()? I don’t see why it wouldn’t receive, but something is obviously not working correctly.

If it doesn’t print at the start (before the code) that means something is up with triggering the event, while if does print that then there’s something wrong with the code inside it.

Yeah It does print when I put it at the top, the code is working

It also prints at the bottom as long as I dont do those two things

I literally even tried taken out the whole code and just putting a task.wait() then a print statement, It still didnt work

Try putting a breakpoint at the first line, and then step through the code. That should show you where everything goes crazy.

At which line in the ClientEvent should I put the breakpoint do you think?

The first line preferably. This will allow you to see where things go wrong from the start

I actuually just fixed it, its super weird but

Basically I had a anotther remote that would load the character and I had that after the FunnyMessage remote, weird thing i dont get is it still worked but I guess it messed with the internals of the code IDK

Thank you @ifkpop for all your help, much appreciated duggy :hearts:

1 Like