#why is this print statement delayed after it fires an event
1 messages · Page 1 of 1 (latest)
just prints m1 attack all the time
but barely works
on server side
(tested on rigs and players both barely work)
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
just do the local createHitbox = workspace:GetPartsBoundsInBox(hitboxCFrame, Hitbox.Size) inside the server
** You are now Level 9! **
yeah i thought that too ngl
did it work?
just gotta wait for my roblox studio to loaddd
💔
can i see your full code of both scripts?
or i could also show you how i handel hitboxes with GetPartBoundsInBox
you decide
** You are now Level 12! **
so what exactly doesn't work again?
barely fires the event
from client to server
well now it just doesnt fire anymore btw
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
Tip : Server barely use waitforchild
m1counter is the amount of times you m1 before it resets
if its ont he server wouldnt it affect everyone
and the m1db
i'll show you an example
ok i see what youre saying
alr
so like when a player joins it just sets their stuff to blah blah n stuff
i hope thats what it is ngl
nah it doesn't have to be that complex you can also just make a table
Basicly
mm ok
You just have to store the m1 number instead of a boolean value then
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
so does it just not work or does it not fire the remote event?
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
so it detects input but it doesn't fire the server?
what ??
oh its keys
uhhhhhhh
ok i gotta refix
i fixed it it works just gotta test out the table stuff
alr
you also have to make an other table for OLDM1
huh
im ngl how do you detect a table of all the inputs
including keyboard and mouse
and other things
what exactly do you mean by detect a table of all inputs
what do you want to detect for example
wait nvm i think i got it just gottta test it out
i was thinking of something like
Enum.UserInputType:GetEnumItems()
you have to make sure its a table by writing local OLDM1 = {} as well
i see
like this?
almost just place the local OLDM1 outside of the function just like you did with M1DB and M1Counter
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
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
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
then it should also fire the event which detects if the player m1ed
debugging rn
alr gl
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)
no i mean local side
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)```
So what is not firing? Because after copying your code it worked fine for me (only the local side)
no clue why it isnt working
Are you really sure that the event does not get fired?
yes because when i click i put a print statement in the onserverevent before the return end thing and it doesnt work
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
ok nevermind it FIRES but it waits a few seconds
you said your roblox studios is kinda slow?
its when i load in
well
nothing else is slow just when i load in
okay maybe its just a ping issue?
MUST... MAKE... M1.... TSB.. MAKES.. IT... LOOK.. FAR... TOOOO... EEAAAASSSSYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
i'll open a new place and see if i can load in faster
hey thats pretty cool man
Pyro Fire save us
fr
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
i do have a working m1 system BUT I HAVE NO IDEA WHAT IT DOESN'T WORK FOR HIM
like come on just a hint
break the problem down into smaller and smaller components untill you cannot split further, focus on individual parts first
alr
bro i didn't even use chatgpt 🥀
like remote not firing - get your remotes in order first
scripts not executing - get your scripts in the right location
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
potato pc
its a literal 11 second delay 💔
studio needs around 4gb ram
there's also a setting that sets deliberate network latency but i'd guess you dont have that on
my physical ram is 16 gb
you also need half decent internet
that don't mean shit if you have 100,000 tabs open in your browser
and windows on its own takes up 2~4gb at least, often more
coz you got too much crap open
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
now i got 5 gb
close all your browsers
and you'll probably have like 8gb+
discord tends to use a fair bit as well
windows updates will completely crush your resources if its running
well how much do you have now?
still 5
deletin the most useless downloads rq