#Points counter showing for everyone and duplicate outputs on FireAllClients()

1 messages · Page 1 of 1 (latest)

grizzled lion
#

Hey! This is simply a bump from a post I made on the dev forum yesterday to see if anyone in here may have a potential solution to try out! I'll leave a link to the post here. Thanks! https://devforum.roblox.com/t/point-counter-playing-for-everyone/3677693

cunning tulip
#

also i feel like this is an issue with the way you might of set up things, anything gui related you want to be for the player only needs to be their playergui and not the surface gui, and make sure verythng u want for the local player in the local script

#

I alao think it might have something to do with your vfx script maybe showing the effect AND the gui

grizzled lion
cunning tulip
#

and ur using playergui instead of startergui?

grizzled lion
#

hold on lemme send the explorer tab

cunning tulip
#

kk ty

grizzled lion
cunning tulip
#

uhm so for the gui for everyone ur saying playergui instead of startergui right?

grizzled lion
#

It's in starterGUI

cunning tulip
#

but when ur calling it in the script are you calling it from the player gui

grizzled lion
#

Are you talking about it being in the PlayerGUI when someone joins?

cunning tulip
#

do you or do you not when you write it in code call it as playergui 😭

#

like

#

local gui = player.playergui.screengui

#

or are you saying

#

local gui = game.startergui.screengui

grizzled lion
#

If you're asking about how I access the Points screenGUI I locate it just using local PointsGUI = script.parent

Sorry i'm having some trouble trying to understand what you're looking to get at

cunning tulip
#

im trying to see if ur typing your script for only the player

#

also for the fireallclient thing

grizzled lion
#

Is there a specific script that I can send the lua code for that would make it easier for you to see?

#

Like do you need the counter?

cunning tulip
#

yes please because im confused 😭

grizzled lion
#

Alright give me a moment

cunning tulip
#

so it might be because the script doesn't check if the current client is the one who actually used the ability it just processes whatever validHit data it receives.

grizzled lion
#

Ohhhh

cunning tulip
#

i think-

grizzled lion
#

It sounds right, because what I was trying to do yesterday was single out the client from the FireAllClients call that actually fired it originally

cunning tulip
#

ah ok

grizzled lion
#

But again, I don't know exactly how to achieve that

cunning tulip
#

maybe try this?

config.playGravityVFX:FireClient(plr, validHit)
#

or wait

#

no

#

pointsEvent:FireClient(plr, victimCharacter)

grizzled lion
#

Would you like to see the knockbackAttributes module script as well? That's where the pointsGUI gets fired to start showing the counter

fresh vectorBOT
#

studio** You are now Level 5! **studio

cunning tulip
#

if u have somwrhing like that

grizzled lion
#

Though I think it's in the post as well

cunning tulip
#

make sure plr, is there

cunning tulip
grizzled lion
#

I think you just came across it actually with the pointsEvent remote

#

But I will send it again

cunning tulip
#

i found the script

grizzled lion
cunning tulip
#

sorry man i dont do visuals very often so

#

im trying my best lol 😭

grizzled lion
#

No problem! I know I put myself in a little bit of a doosey with this

cunning tulip
#

i like cant pinpoint what wrong

#

whats*

#

like it looks right :Sob:

grizzled lion
#

Though the VFX themselves are functioning as intended so that part is completely fine, just this thing related to the points counter

cunning tulip
#

we might need to wait for the big scripters to show up 😭

#

sorry

grizzled lion
#

If you know anyone point them to here

cunning tulip
#

kk will do

grizzled lion
#

It's gonna end up being something stupidly simple

#

One of those needle in a haystack problems because everything else is functioning fine

grizzled lion
# cunning tulip kk will do

Hey, I've been trying to understand it a bit more and I tried putting it into a video to make it clearer to understand. https://www.youtube.com/watch?v=32rWWs6YdNk

The local victimVFX = config.playGravityVFX.OnClientEvent:Connect(function(pChar, validHit) function gets played based on how many people are in the server because the fire server request noted as config.gravityValidator:FireServer(pChar, vTable) is sent to EVERYONE which then means all people in the server will fire that FireAllClients request, causing what looks like multiple code loops. I don't know if that adds anything but I only need ONE person to fire config.gravityValidator:FireServer(pChar, vTable) then I believe I will be closer to the solution!

#

Know anyone that may be able to help?

tawny roost
#

what is the problem exactly?

tawny roost
grizzled lion
# tawny roost what is the problem exactly?

The problem is that in my client VFX handler, after the hitbox of the ability comes out it fires back to the server for validation and then returns it to all clients so they can see the effects of the victims that got hit. What's happening is that ALL the clients are firing this line: config.gravityValidator:FireServer(pChar, vTable)

This then causes EVERY client to fire the validator and then subsequently every player in the server FiresAllClients, resulting in this block running multiple times based on how many people are in the server:

local victimVFX = config.playGravityVFX.OnClientEvent:Connect(function(pChar, validHit) --processed hits are returned here to play effects.
            
        --Everything from this point gets repeated based on how many players there are in the server?
            
        warn(pChar.Name.." has returned to the VFX handler with a validated table of hit players.")
    
            if #validHit == 0 then
                print("Nobody was hit!")
                return
            else
                config.gravityCatch:Play()
                for _, vChar in pairs (validHit) do
                    
                    print("Hit")
                    
                    local vTorso = vChar:WaitForChild("LowerTorso")

                    local victim = vChar.Humanoid.Animator:LoadAnimation(config.gravityVictim)
                    local swirlClone = config.gravitySwirl:Clone()
                    victim:Play()
                    swirlClone.Parent = vTorso
                    swirlClone:Emit(5)
                    
                    task.delay(1.5, function()
                        swirlClone:Destroy()
                        config.gravityRelease:Play()
                    end)
                end
            end    
        end)
#

I need a way to make only the player who initiated the ability fire back to the server.

grizzled lion
tawny roost
#

but it sounds like you have infinite loop of remotes?

#

also can you tell me what this is? it's in your thread ```lua
config.abilityRemote.OnServerEvent:Connect(function(plr, remote)

remote:FireAllClients(plr)
print("Ability Recieved!")

end)```

grizzled lion
#

It FiresAllClients multiple times based on how many players are in the server

grizzled lion
#

this:

local RS = game:GetService("ReplicatedStorage")
local PLRS = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local SS = game:GetService("ServerStorage")

local plr = PLRS.LocalPlayer
local pChar = plr.Character

local abilityRemote = RS.Events:WaitForChild("AbilityRemote")
local gravityEvents = RS.Events:WaitForChild("GravityEvents")
local gravityVFX = gravityEvents:WaitForChild("GravityVFX")

local cooldown = 3
local canUseAbility = true

--Hitbox is created on the client for WYSIWYG flow. We will need checks on the server side for exploit purposes
UIS.InputBegan:Connect(function(input, gameProcessed)
    
    if gameProcessed then
        return
    end
    
    if input.KeyCode == Enum.KeyCode.Q and canUseAbility then
        
        canUseAbility = false
        print(script.Name.." Fired!")
        abilityRemote:FireServer(gravityVFX)
        
        task.delay(cooldown, function()
            canUseAbility = true
        end)        
    end
end)
tawny roost
#

so yea its that code

grizzled lion
#

This is the problem?

tawny roost
#

there's yer problem fingerguns

grizzled lion
#

Or the little line?

tawny roost
#
config.abilityRemote.OnServerEvent:Connect(function(plr, remote)
    
    remote:FireAllClients(plr)
    print("Ability Recieved!")
    
end)```
there are so many things wrong with this design pattern i almost don't even know where to start except be thankful it isnt targeted
#

if you wrote it like this

#
config.abilityRemote.OnServerEvent:Connect(function(plr, remote,tgt)
    
    remote:FireAllClients(tgt)
    print("Ability Recieved!")
    
end)``` i would be terrified
grizzled lion
#

Is there any good resource for making client sided hitboxes with a VFX handler that you know of?

#

Because ive been making this up as I go

tawny roost
grizzled lion
tawny roost
#

and honestly simplest solution here is to use 2 different remotes, one for vfx another for the inputs, or whatever it is you're doing

#

instead of this disaster: ```lua
config.abilityRemote.OnServerEvent:Connect(function(plr, remote)

remote:FireAllClients(plr)
print("Ability Recieved!")

end)```

#

most of your ability code should be in there, idk why it isnt?

grizzled lion
#

What I want to happen is:

Ability gets sent from local script to server script
Server fires all clients to the VFX handler for everyone to see
Hitbox gets created on the VFX handler and then fires to the server to validate the hitbox
After validation, the valid hits get sent back to the VFX handler so everyone can see the effects on who got hit

tawny roost
#

perhaps that is why the hitbox happens on all clients?

#

🦆

grizzled lion
#

I originally had the hitbox on the local script where the ability is pressed, but I wanted to have the hitbox come out after a GetMarkerReachedSignal point is passed so I can control them better.

#

I wanted ALL of the VFX to be in one script, which included the hitbox since it was a visual thing that would then get validated

#

Should the hitbox be in the script that casts the ability then?

grizzled lion
#

task.delay()?

#

Use that for the actual hitbox itself and then the VFX can run everything else in its own handler?

tawny roost
#

as soon as the server is aware the player has started the ability then the server can just set a timer for when that ability will hit, it doesn't need 2 remotes for one to start and the other to hit

#

anyway, hitboxes are not for beginners

#

maybe try something easier

#

or you could also iterate, basically junk the code you have and try again.

#

aka refactor

#

In computer programming and software design, code refactoring is the process of restructuring existing source code—changing the factoring—without changing its external behavior. Refactoring is intended to improve the design, structure, and/or implementation of the software (its non-functional attributes), while preserving its functionality. ...

grizzled lion
#

I feel like I have a lot of major pieces already, but I'm going to rewrite parts of it and see what I get out of it

#

But if you were to give me one last piece of advice, the client sided hitbox should be on the ability casting local script yes?

tawny roost
#

yeah getting that first iteration down like actually playing the vfx in somewhat of correct context is the first part, you then take that and put it in a revised context so it works better

#

very normal, i've thrown out tonnes of code

tawny roost
grizzled lion
#

I messed around with server-sided hitboxes and didnt like the delay

#

and some module scripts as well that helped combat it a bit

tawny roost
#

roblox doesn't have lag compensation / clientside prediction

#

so you either make one or accept the delay like every other roblox game. not even tsb has prediction. it's all server-sided, delay and all.

grizzled lion
#

Oh interesting

tawny roost
#

yeah its just tsb is so freakin' popular that there's enough servers for one to be close enough to you that your ping doesnt suck

grizzled lion
#

Never really thought about like that

#

I'm gonna study it a bit more, definitely rewrite some stuff and get rid of

#
config.abilityRemote.OnServerEvent:Connect(function(plr, remote)
    
    remote:FireAllClients(plr)
    print("Ability Recieved!")
    
end)
#

this

tawny roost
#

next time u on there taking notes, open f7 and pay very close attention to the delay between clicking and the character actually throwing an m1 against your ping.

#

same for ability

grizzled lion
#

Oh what do I need to change for that again?

tawny roost
#

wat

grizzled lion
tawny roost
#

wat no im talking about when u next play on tsb

grizzled lion
#

Oh LOL

tawny roost
#

no doubt that's what your inspiration is

#

everyone wants to make a combat game, and now everyone wants to make a grow a something game

grizzled lion
#

Yea I wanna figure out how all that sorta works

fresh vectorBOT
#

studio** You are now Level 6! **studio

tawny roost
#

why not go for a bluelock game and you've hit the trifecta!

#

and chuck in a train system while you're at it fingerguns

#

bloxfruits on the other hand i'm fairly sure has prediction

#

at least to some degree, i.e when you throw an ability it immediately plays on your client, unlike tsb