#my variable gets turned into a boolean for some reason thru remote event

1 messages · Page 1 of 1 (latest)

stark cliff
#

this may be a really stupid issue but i dont understand why this happens so i need help or someone to explain it to me

this is where it sends

if heavyPunch == true then
currentDamage = 10
end

        event:FireServer(attacker, hit, victim, heavyPunch, currentDamage)

here is the server script

event.OnServerEvent:Connect(function(attacker, hit, victim, heavyPunch, currentDamage)

humanoid:TakeDamage(currentDamage)
print("damaged for " ..tostring (currentDamage))

it returns damaged for false

obviously this is just snippets of my code but its the important parts i can send everything if u want

fallen iron
#

when you fire the server from a client script, it will always send the player the client script is sending from

#

so it would also send the player variable

#

so you dont really have to explicitly send the attacker, leave it empty

#

keep it on the OnServerEvent though, the attacker variable will be already filled with the player variable

stark cliff
#

i mean the currentDamage gets turned into a boolean even tho i want to send a number

blazing quarryBOT
#

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

fallen iron
#

its basically like:
you :FireClient(attacker,hit,victim,heavypunch,>currentdamage<)
when received .OnServerEvent(player, attacker, hit, victim,> heavypunch<, currentdamage)
player variable is put at the very front, causing the order to push forward and have every variable be overriden by the variable infront of them

stark cliff
#

My bad i mean on local script

#

Since i need to keep it OnServerEvent

fallen iron
#

you'll keep "attacker", or replace it as any other name on the server script

#

remove it from the client script

stark cliff
#

Alright thank you 🙏

faint spear
#

@stark cliff I’d also like to add that your remote function can be easily faked by a hacker.

#

I’d recommend adding sanity checks to your .OnServerEvent function

stark cliff
#

Chill bruh im tryna learn basics rn 🙄

faint spear
#

Remember, never trust the client.

#

Always double check on the server

stark cliff
#

alright

rich pollen
#

the basics are understanding how remotes work

#

then, it'll come from yourself on how to make them safe

faint spear
rich pollen
#

remote:fireserver(player, args)

#

are we deadass

faint spear
rich pollen
faint spear
rich pollen
#

oh really

#

let's see you do it

#

what will he check

#

if not player then return end

faint spear
rich pollen
#

do it

faint spear
rich pollen
#

Error: attempt to index number with IsA

#

do u deadass not know how to check ur game against hackers

#

the tables have turned

faint spear
#

That’s what luau dose vs lus

#

Or

#

Just use type()

rich pollen
#

your code broke btw