#Killing a player with a script
117 messages · Page 1 of 1 (latest)
So you want to kill the player, right?
You could teleport him to where it will respawn or kill him and it will respawn
** You are now Level 32! **
!rank
teleporting wont work
and i cant kill a player when hes in a lobby
i said i need a way to respwan him
not to teleport
is this server script
yes
try take damage method
and what is that
humanoid:TakeDamage(9999)
ohhh
ok
ill try
allso how do i reference the chrachter in a server script
cus there is no LocalPlayer in a server script
But thats killing him, something that I said and he told he doesnt want that
bruh i cant read
Depends on your script
no i said i want that
As long as you have the player you can easily get the character by just looking for the model
he says respawn
bruh in a script
Player.Character
Yea, in a script
in a local script its Player.LocalPlayer.Charachter
Oh yea, I guess it can use that too
in server script its Player.Character
k thanks
mind blowing
didnt work
idk if theres a bug or im just stupid
Humanoid.Health = 0
bro i tried that
Any error in output?
Hold up
spelling error
local function respawn(part)
part.Parent:FindFirstChild("Humanoid):TakeDamage(999)
end
touchpart.Touched:Connect(respawn)
You forgot to close ""
i fixed that
** You are now Level 5! **
But you should check if part is a child of a model
dw
gah damn finnaly it works
thank you so much
np
local function respawn(part)
local char = part.Parent
if not char then return end
local hum = char:FindFirstChild("Humanoid")
if not hum then return end
hum:TakeDamage(999)
end
touchpart.Touched:Connect(respawn)
can i use a , to connect another local fucnction
This way you will not encounter any issue
dw it allready works
thanks for helping
If any other part that is not an child of player's model touch that, it will cause you an error, better safe than sorry
alright
no
function onRespawn()
--code
end
function onTouch(part)
local char = part.Parent
if not char then return end
local hum = char:FindFirstChild("Humanoid")
if not hum then return end
hum:TakeDamage(999)
onRespawn()
end
touchpart.Touched:Connect(onTouch)
You could do something like this
oh that works too
didnt think abt that
thanks
Thank you so much @wide marten and @mellow isle
wait
wth
You're welcome
didnt work
ontouched function takes an argument
and how do i fix it
and how does it even take an argument
if its on another line
onTouched(otherPart) the otherpart is the argument
You should add in () the part variable
function onRespawn(otherpart)
print(otherPart)
end
function onTouch(part)
local char = part.Parent
if not char then return end
local hum = char:FindFirstChild("Humanoid")
if not hum then return end
hum:TakeDamage(999)
onRespawn(part)
end
touchpart.Touched:Connect(onTouch)
gah damn it finnaly works
everything works
thank you so much man
Here is an example:
function func2(i)
print("Function 2: "..i)
end
function func1(n)
print("Function 1: "..n)
func2(n)
end
func1("Hi There")
;compile
Function 1: Hi There
Function 2: Hi There
but why does everything change when you type in the (n) for example
At which line?
and if you keep it empty
when its the func2(n)
im just wondering
like its not in my code im just wondering why is there a big difference between keeping it empty or typing something there
the function takes in an argument
;compile
function func2(i)
i += 1
print("Function 2: "..i)
end
function func1(n)
n += 1
print("Function 1: "..n)
func2(n)
end
func1(1)
-------------
function func2_new()
print("Function 2: empty")
end
function func1_new(n)
n += 1
print("Function 1: "..n)
func2_new()
end
func1_new(1)
/opt/wandbox/lua-5.4.3/bin/lua: prog.lua:2: syntax error near '+'
shit, I fucked up with the syntax, I write it in Discord lol
ah yes, same name functions, Im smart
k
Ok Im sad now, wait a sec
When I will show you an example that actually work lol
nvm, its working...
Looks like the compile bot is just dumb
Hope so, Im not that good at teaching and/or explaining
and im not good at learning