#why is this print statement delayed after it fires an event

1 messages · Page 1 of 1 (latest)

tropic orbit
#

just prints m1 attack all the time

#

but barely works

#

on server side

#

(tested on rigs and players both barely work)

cedar cobalt
#

don't check for hitboxes on the client in general becaus im pretty sure exploiters could just fire your remote even with a player of their choice without even hitting them

#

and they can also just get rid of the "humsHit[v.Parent.Name] = true" for example

#

so people would pretty much just get one shot

#

So its best if you validate everything on the server so that exploiters can't just spamm your remote event and one shot other players without even beeing near them

tropic orbit
#

i just did this instead

#

this alr?

#

nvm i broke the entire thing

cedar cobalt
#

just do the local createHitbox = workspace:GetPartsBoundsInBox(hitboxCFrame, Hitbox.Size) inside the server

lyric jettyBOT
#

studio** You are now Level 9! **studio

cedar cobalt
#

did it work?

tropic orbit
#

just gotta wait for my roblox studio to loaddd

cedar cobalt
#

💔

tropic orbit
#

yeah its been running rlly slow recently

#

for no reason

#

it didnt work

cedar cobalt
#

can i see your full code of both scripts?

#

or i could also show you how i handel hitboxes with GetPartBoundsInBox

#

you decide

tropic orbit
lyric jettyBOT
#

studio** You are now Level 12! **studio

tropic orbit
#

last one is server side obviously

#

rest is local

cedar cobalt
#

so what exactly doesn't work again?

tropic orbit
#

barely fires the event

#

from client to server

#

well now it just doesnt fire anymore btw

cedar cobalt
#

hm so it has to do something with your M1DB.
First of all i would do the whole M1Counter and M1DB on the server as well because exploiters can still spam m1 then.
Then I would check when exactly your DB is false or true by printing when you change it in your code and when you m1 overall.

#

so then you can see the last time it was set to true and change the code accordingly or find the mistake faster

uncut talon
#

Tip : Server barely use waitforchild

tropic orbit
#

m1counter is the amount of times you m1 before it resets

#

if its ont he server wouldnt it affect everyone

#

and the m1db

cedar cobalt
#

And the solution for that are tables

#

you store the m1db of a player inside a table

tropic orbit
#

so like

#

attributes

#

or sum

#

OH

cedar cobalt
#

i'll show you an example

tropic orbit
#

ok i see what youre saying

cedar cobalt
#

alr

tropic orbit
#

so like when a player joins it just sets their stuff to blah blah n stuff

#

i hope thats what it is ngl

cedar cobalt
#

nah it doesn't have to be that complex you can also just make a table

tropic orbit
#

send an example to me so i can just

#

learn

#

n stuff

cedar cobalt
#

This is how it would look like for example

tropic orbit
#

so is the M1 counter also a table?

#

or somethin

cedar cobalt
#

Basicly

tropic orbit
#

mm ok

cedar cobalt
#

You just have to store the m1 number instead of a boolean value then

tropic orbit
#

i just did something like M1Counter[player]<4 and stuff

#

now my uis localscript thing is just fire server

#

peak

#
local RS=game:GetService("ReplicatedStorage")

local Remotes=RS:WaitForChild("Remotes")
local Animations=RS:WaitForChild("Animations")

local M1AttackRemote=Remotes:WaitForChild("M1Attack")

local PLRS=game:GetService("Players")

local M1DB={}

local M1Counter={}

local TIME_TILL_RESET=1.5

local function M1Time(player : Player,Time, M1Animation)
    task.wait(M1Animation.Length + Time)

    M1DB[player]=false

    task.spawn(function()
        local OLDM1=M1Counter[player]
        task.wait(TIME_TILL_RESET)
        if OLDM1==M1Counter[player] then
            M1Counter[player]=0
        end
    end)
end

M1AttackRemote.OnServerEvent:Connect(function(player)
    if M1DB[player] then return end
    local hitboxCFrame=player.Character:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0,0,-4)
    local hitboxSize=Vector3.new(6,6,6)

    local createHitbox=workspace:GetPartBoundsInBox(hitboxCFrame,hitboxSize)
    local hum=player.Character:WaitForChild("Humanoid")
    
    local M1=Animations:WaitForChild("M1")
    local M1Animation=hum.Animator:LoadAnimation(M1)
    
    local humsHit={}

    for i, v in pairs(createHitbox) do
        if v.Parent:FindFirstChild("Humanoid") and not humsHit[v.Parent.Name] and v.Parent ~= player.Character then
            humsHit[v.Parent.Name]=true
            
            v.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
        end
    end
    
    if M1Counter[player]<4 then
        M1Time(player, 0.35, M1Animation)
    elseif M1Counter[player]==4 then
        M1Time(player, 0.7, M1Animation)
        M1Counter[player]=0
    end
end)``` server side
#

still doesnt work, def the local side then

cedar cobalt
#

so does it just not work or does it not fire the remote event?

tropic orbit
#

i did this for debugging purposes the for loop doesnt even print anything

#

nvm it does something now

#

just gotta test the input2 userinput type and see what it says n stuff

cedar cobalt
#

so it detects input but it doesn't fire the server?

tropic orbit
#

what ??

#

oh its keys

#

uhhhhhhh

#

ok i gotta refix

#

i fixed it it works just gotta test out the table stuff

cedar cobalt
#

alr

cedar cobalt
tropic orbit
#

im ngl how do you detect a table of all the inputs

#

including keyboard and mouse

#

and other things

cedar cobalt
#

what exactly do you mean by detect a table of all inputs

#

what do you want to detect for example

tropic orbit
#

wait nvm i think i got it just gottta test it out

#

i was thinking of something like

#

Enum.UserInputType:GetEnumItems()

cedar cobalt
cedar cobalt
tropic orbit
#

like this?

cedar cobalt
#

almost just place the local OLDM1 outside of the function just like you did with M1DB and M1Counter

tropic orbit
#

this looks like it'll work

#

wait thats just doing the same thing

#

ma

#

man

#

you know how like uis has keyboard mouse and other sorts of things

cedar cobalt
#

UIS.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
M1RE:FireServer()
end)

maybe try this?

#

yea

tropic orbit
#

ok nvm ill just try that solution

#

ok anyways

#

you know how inputs can be just separate

#

what happens if you do something like

#

pressing a while clicking

cedar cobalt
#

then it should also fire the event which detects if the player m1ed

tropic orbit
#

oh

#

yay now local side works

#

with your provided script

cedar cobalt
#

gud

#

what about server side?

tropic orbit
#

debugging rn

cedar cobalt
#

alr gl

tropic orbit
#

uhh the thing is

#

it still doesnt fire

cedar cobalt
#

what

#

show me your code again

tropic orbit
#
local RS=game:GetService("ReplicatedStorage")

local Remotes=RS:WaitForChild("Remotes")
local Animations=RS:WaitForChild("Animations")

local M1AttackRemote=Remotes:WaitForChild("M1Attack")

local M1DB={}

local M1Counter={}

local OLDM1={}

local TIME_TILL_RESET=1.5

local function M1Time(player : Player,Time, M1Animation)
    task.wait(M1Animation.Length + Time)

    M1DB[player]=false

    task.spawn(function()
        OLDM1[player]=M1Counter[player]
        task.wait(TIME_TILL_RESET)
        if OLDM1[player]==M1Counter[player] then
            M1Counter[player]=0
        end
    end)
end

M1AttackRemote.OnServerEvent:Connect(function(player)
    if M1DB[player] then return end
    M1DB[player]=true
    local hitboxCFrame=player.Character:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0,0,-4)
    local hitboxSize=Vector3.new(6,6,6)

    local createHitbox=workspace:GetPartBoundsInBox(hitboxCFrame,hitboxSize)
    local hum=player.Character:WaitForChild("Humanoid")
    
    local M1=Animations:WaitForChild("M1")
    local M1Animation=hum.Animator:LoadAnimation(M1)
    
    local humsHit={}
    
    for i, v in pairs(createHitbox) do
        if v.Parent:FindFirstChild("Humanoid") and not humsHit[v.Parent.Name] and v.Parent ~= player.Character then
            humsHit[v.Parent.Name]=true
            
            v.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
        end
    end
    
    if M1Counter[player]<4 then
        M1Time(player, 0.35, M1Animation)
    elseif M1Counter[player]==4 then
        M1Time(player, 0.7, M1Animation)
        M1Counter[player]=0
    end
end)
cedar cobalt
#

no i mean local side

tropic orbit
#
local RS=game:GetService("ReplicatedStorage")
local UIS=game:GetService("UserInputService")
local Remotes=RS:WaitForChild("Remotes")
local M1AttackRemote=Remotes:WaitForChild("M1Attack")

UIS.InputBegan:Connect(function(input, GPE)
    if GPE then return end
    if input.UserInputType~=Enum.UserInputType.MouseButton1 then return end
    
    M1AttackRemote:FireServer()
end)```
cedar cobalt
#

So what is not firing? Because after copying your code it worked fine for me (only the local side)

tropic orbit
#

no clue why it isnt working

cedar cobalt
#

Are you really sure that the event does not get fired?

tropic orbit
#

yes because when i click i put a print statement in the onserverevent before the return end thing and it doesnt work

cedar cobalt
#

So i only have 2 more ideas

#

First idea is removing all the WaitForChild() functions when refercing your replicated storage and your remote event because they are already replicated the moment your character loads in

#

2nd idea is checking if your RemoteEvents i really called M1Attack

#

If that won't help you then im out of ideas

tropic orbit
#

ok nevermind it FIRES but it waits a few seconds

cedar cobalt
#

okay...

#

thats good

#

or better

tropic orbit
#

idk where the sevonds came from

#

seconds

cedar cobalt
#

you said your roblox studios is kinda slow?

tropic orbit
#

its when i load in

cedar cobalt
#

well

tropic orbit
#

nothing else is slow just when i load in

cedar cobalt
#

okay maybe its just a ping issue?

spark sky
#

MUST... MAKE... M1.... TSB.. MAKES.. IT... LOOK.. FAR... TOOOO... EEAAAASSSSYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

tropic orbit
#

i'll open a new place and see if i can load in faster

tropic orbit
#

fr

spark sky
# cedar cobalt Pyro Fire save us

bro can't be saved they're trying to stitch chatgpt slop together until tsb comes out and they can barely get a remote event working

cedar cobalt
#

i do have a working m1 system BUT I HAVE NO IDEA WHAT IT DOESN'T WORK FOR HIM

spark sky
cedar cobalt
#

alr

tropic orbit
spark sky
#

like remote not firing - get your remotes in order first

#

scripts not executing - get your scripts in the right location

tropic orbit
#

why is this print statement delayed after it fires an event

#

we fixed the remote problem (i wasn't thinking its 2 am) now its just the delay problem

#

and also roblox studio is still slow when i play in a new place

spark sky
#

potato pc

cedar cobalt
#

💔

#

try restarting maybe or check how your task manager is doing

tropic orbit
#

its a literal 11 second delay 💔

spark sky
#

studio needs around 4gb ram

#

there's also a setting that sets deliberate network latency but i'd guess you dont have that on

tropic orbit
#

my physical ram is 16 gb

spark sky
#

you also need half decent internet

spark sky
tropic orbit
#

why is my available ram 4.5 gb

#

😭

spark sky
#

and windows on its own takes up 2~4gb at least, often more

spark sky
#

10 browser windows with 100k tabs each consumes a lot of ram y'know

#

in fact probably only reason you have 4.5gb is because the other processes are trying to conserve memory to make space for studio

tropic orbit
#

now i got 5 gb

spark sky
#

and you'll probably have like 8gb+

tropic orbit
#

the only apps i got is opera gx

#

roblox studio

#

and system info

spark sky
#

close all games you have running in background

#

yea close opera gx

tropic orbit
#

alr did just now

#

im texting on opera

spark sky
#

discord tends to use a fair bit as well

tropic orbit
#

gained air from closing opera

#

peak

spark sky
#

windows updates will completely crush your resources if its running

cedar cobalt
#

well how much do you have now?

tropic orbit
#

still 5

cedar cobalt
#

cooked

#

well im sorry but idk if i can help you fix your ram problem

tropic orbit
#

deletin the most useless downloads rq

cedar cobalt
#

alr

#

tell me when you don't have 11 seconds delay anymore 💔 and when you run into another problem

pine spade
#

reinstall windows

#

yeah get a better internet maybe

tropic orbit
#

how the hecc

#

did i go from 5 gb

#

to 4.98 gb

#

by deleting stuff

#

imma just tag this as solved