#Remote Event Firing 3 times upon activation (one trigger)

1 messages · Page 1 of 1 (latest)

topaz kindle
#

this is the attempted fixed version of the client side sending to remote event

if not alreadyConnected then
    alreadyConnected = true

    UIS.InputBegan:Connect(function(input)
        if input.KeyCode == Enum.KeyCode.F and db == false then
            blocking = true
            blockstart:Play()
            blockhold:Play()
            game.ReplicatedStorage.BlockEvent:FireServer()
        end
    end)

    UIS.InputEnded:Connect(function(input)
        if input.KeyCode == Enum.KeyCode.F then
            blocking = false
            blockstarted = false
            blockhold:Stop()
            blockend:Play()
            game.ReplicatedStorage.UnblockEvent:FireServer()
        end
    end)
end
#

and this is the server side remote event

#

game.ReplicatedStorage.BlockEvent.OnServerEvent:Connect(function(plr)
    print("Blocking")
    plr.Character.Humanoid.WalkSpeed = 2
end)

game.ReplicatedStorage.UnblockEvent.OnServerEvent:Connect(function(plr)
    print("Unblocking")
    plr.Character.Humanoid.WalkSpeed = 16
end)

#

(ping me)

topaz monolith
#

blocking blocking unblocking?

topaz kindle
#

can you elaborate, im half asleep right now, even while writing the code

topaz monolith
#

what do u get printed?

#

i wanna tell which prints how many times

topaz kindle
#

Blocking x3
Unblocking x3

topaz monolith
#

oh like that

#

would u be able to share whole code?

#

id believe youre connecting few times somehow

topaz kindle
#

yes, allow me a moment to reboot studio

#

actually well

dusky cairnBOT
#

studio** You are now Level 3! **studio

topaz kindle
#

it'd have to be in a file

#

because its well over 2k chars long

#

(its the entire combat client)

topaz monolith
#

maybe ss?

#

would be easier

#

if u can fit larger amount of code

topaz kindle
#

client sided

#

server sided

#

the reason why there is a hold block thing, is i was trying to make a hold and toggle option for it

#

and then thats when i noticed the problem, and even when i deleted all of the toggle code, it still persisted

#

which absolutely dumbfounded me

topaz monolith
#

its very weird

#

but i noticed that

#

please use task.spawn

#

not just spawn

#

🙏

topaz kindle
#

can you tell me the difference between the two?

simple karma
#

one is deprecated

topaz monolith
#

i believe spawn isnt supposed to be used to

#

yea

#

i cant ever spell that

#

just like wait vs task.wait

topaz kindle
#

same result

topaz monolith
#

yea it wont fix that just better if you use

topaz kindle
#

i see

topaz monolith
#

would u maybe try printing anything when inputbegin

#

or smth?

#

cuz its very weird

simple karma
#

just use new ias icl

topaz monolith
#

yup prob better

#

i cant rly help with that tho, didnt give it a try yet

simple karma
#

my blocking on ias works fine

topaz kindle
#

oh wait

#

no

#

i messed it up

#

one sec

ruby drum
#

.

topaz kindle
#

hey you accidentally put stuff on the wrong line sometimes too

simple karma
topaz kindle
#

I KNOWWW 😭

#

okay i jhust change dit

simple karma
#

also

#

i dont see u defining

#

alreadyblocking variable

#

ur defining it after the conditional

#

the first check would be nil so it would continue

topaz kindle
#

i have them all up here

simple karma
#

just try defining it if it helps

topaz monolith
#

u sure u dont like somehow got the same code in 3 diffrent scripts?

simple karma
topaz kindle
topaz kindle
topaz monolith
#

at this point rename remote and pray that was the issue

#

that other script was using it

#

🙏

topaz kindle
#

ai tells me nothigns wrong with it

#

othe rpeople tell me nothings wrong with it

#

do i need an excorsism

#

or something

topaz monolith
#

i was about to say that

#

lmao

simple karma
#

yeah uhh

topaz monolith
#

try renaming remote

simple karma
#

try removing thr conditional

topaz monolith
#

or i can get u chat gpt ah code that should tell u where fire server was called from

#

to see if other is firing it

topaz kindle
#

okay so

simple karma
#

doesnt seem like ur using thr var anyway

topaz kindle
#

iu didnt change anything

#

and

#

now its working as intended

#

i am beyond confused

topaz monolith
#

roblox studio moment

topaz kindle
#

i am beyond confused

#

what the fuck

#

i didnt change anything

topaz monolith
#

dont question it before it breaks

#

do u have potato by any chance

#

as in pc

topaz kindle
#

no

topaz monolith
#

aw

topaz kindle
#

big beefy pc

jovial flint
#

new IAS is pretty good btw

topaz kindle
topaz monolith
#

i thought maybe studio didnt shut down correctly somehow

topaz monolith
simple karma
topaz monolith
#

that sums up all devices

simple karma
#

beta feature

topaz kindle
#

oohh okay

#

ill give it a shiot

simple karma
topaz monolith
#

wa

simple karma
# topaz kindle ill give it a shiot
#

also

topaz kindle
#

also, another question on the server side of thing since this now magically works

simple karma
#

instead of defining all the animations manually one by one

#

put them into a table and iterate over it

#

will be easier

topaz kindle
#

i see

topaz kindle
# simple karma what

probably dumb question, but im sleep deprivated as hell right now and cant think 100% properly

#

since im making a block system, i need it to recognize that

#

the other player is blocking

#

how can i do that

simple karma
#

give attribute

jovial flint
#

Make a state machine?

dusky cairnBOT
#

studio** You are now Level 2! **studio

topaz monolith
#

keep table of

simple karma
#

check if blocking

topaz monolith
#

blocking[player] = bool

simple karma
#

or that

#

or just

#

get a state machine

topaz kindle
#

what is a state machine?

simple karma
#

manages player states

#

like blocking ragdolled

#

but for i

#

for u

#

just use attributes

#

since ur new to this

topaz kindle
simple karma
#

refine ur code and use a state machine later

jovial flint
#

Worth learning state machines though, will come in handy later down the line

simple karma
#

wow really

topaz kindle
dusky cairnBOT
#

studio** You are now Level 4! **studio

topaz kindle
#

can you give me a quick example?

simple karma
#

for

#

initializing arteibute

#

attribute?

topaz kindle
#

yes

simple karma
#

im on phone buthere

#

local attributes = {“Blocking” = false}

game.Players.PlayerAdded:Connect:function(Player: Player)
for name, value in attributes do
Player:SetAttribute(name, value)
end
print(‘initialized all attributes for {Player.Name}’)
end)

topaz kindle
#

and then this would apply to every player that is joining, and i'd use the client side script to trigger the remote event to make it true?

simple karma
#

yes

#

yes

topaz kindle
#

got it

simple karma
#

u should

topaz kindle
#

i apprecaite it

simple karma
#

learn module loaders

#

theyre easy and clean

#

good if u learn them early on

topaz kindle
#

ill take a look at it right now

#

i think i need to go to bed 😭

simple karma
#

wonderful

topaz kindle
#

okay so for these attributes

#

where can i access and reference them for later use

#

if its like this wouldnt it just be like this

#
game.Players.PlayerAdded:Connect:function(Player: Player)
  Player:SetAttribute(IsBlocking, true)
if Player.IsBlocking == true then
  print("placeholder")```
#

or would it be under a different directory

#

(i would check this right now, but im not on my pc)

simple karma
#
#

also when u do getattribute in a variable

#

and the attribute value changes

#

variable doesnt

topaz kindle
#

so how DO i index it?

topaz kindle
simple karma
topaz kindle
#

im gonna put all this in a folder and read it when my brain isn't running off of 4 mountain dews and a dream