In this screenshot I have a server script that prints “firing ded” and fires a remote event to a local script which prints “someone died in team(…)”, however you can see very clearly that the local script doesnt always detect when the remote event fires and only the server script ends up printing. How can I fix this?
First off, could you show me both local and server script?
local script:
local function addFighter(f)
table.insert(fighters, f)
table.insert(active, f)
fighter = f
update()
f:FindFirstChild('Humanoid').ded.OnClientEvent:Connect(function()
table.remove(active, table.find(active, f))
print('someone died in team '..i..',',#active,'left')
if #active < 1 then
gui.MatchLost:Fire(frame.Name)
end
update()
end)
end
server script (in humanoid)
local ded = false
script.Parent.Parent.HealthChanged:Connect(function(health)
if health <= 0 and not ded then
ded = true
print('firing ded')
script.Parent:FireAllClients()
end
end)
uhm isnt the client supposed to fire to the server
the server is firing to the client in my script
and also try using a loop function
I tried using a while loop before and it didn’t work
I have many questions about this.
Why did you parent a server script to a RemoteEvent?
What is the dataType of f
? This might be the root cause of the issue.
woah lol i didnt even notice that lmao. Ur not supposed to make the script a child to a remote event
Also the function needs to check if the thing like the rig has a humanoid in it
f is an NPC model. I parented the server script to remote event so that I could just use f.Humanoid.ded instead of f.Humanoid.Script.ded
what’s wrong with that, does it affect the event in any way? if so, what is the proper way to set it up?
the remote event is inside of the humanoid.
Remote Events should be in a place where both the server and client can access. In practical terms, it means they should be in game.ReplicatedStorage
.
exactly said what i was about to say lol
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.