#simple issue but i dont know how to fix?

1 messages · Page 1 of 1 (latest)

calm finch
#
local character = plr:WaitForChild("Character")
local humanoid = character:WaitForChild("Humanoid")

if humanoid.Health == 0 then
    game.ReplicatedStorage.death:FireServer()
    
end```
#
game.ReplicatedStorage.death.OnServerEvent:Connect(function(plr)
    local leaderstats = plr:WaitForChild("leaderstats")
    local time = leaderstats:WaitForChild("Time Alive")
    
    time.Value = 0
end)```
steep marten
#

Do humanoid.changed

high widget
#

Do humanoid.died:connect(replicatedevent)

high widget
steep marten
#

Or died is the one im thinking of

#

Mb

#

I forgot the property

#

Forgive me

high widget
#

All good brother

#

I forgive you 😭

#

🔥

calm finch
#
local character = plr:WaitForChild("Character")
local humanoid = character:WaitForChild("Humanoid")
local death = game.ReplicatedStorage.death

if humanoid.died:connect(death) then
    game.ReplicatedStorage.death:FireServer()
end```
#

ddoesnt work

#

@steep marten

steep marten
#
humanoid.Died:Connect(function()
  game:GetService("ReplicatedStorage):WaitForChild("death"):FireServer()
end)```
#

@calm finch

calm finch
#

ohh

steep marten
#

yeshir

calm finch
#
    local leaderstats = plr:WaitForChild("leaderstats")
    local time = leaderstats:WaitForChild("Time Alive")
    
    time.Value = 0
end)```
#

is this correct?

#

it doesnt reset time

#

can you check if this works

#

@steep marten

#

this is another script

steep marten
#

instead of game.replicated storage do game:getservice("replicatedstorage)

calm finch
#

is that ok?

smoky gyro
#

ur using onServerEvent

#

in local script

calm finch
#

nono

#

thats in server script service

steep marten
#

no the onserverevent is in server

#

yeah

smoky gyro
#

oh

calm finch
#

let me screen shot my explorer

steep marten
#

the function is called from startercharacterscripts

#

i got it

calm finch
#

any issues there?

steep marten
#

yes

#

startercharacterscripts are a child of the character

#

which is a child of the workspace

#

localscripts dont run on the workspace

calm finch
#

mm

steep marten
#

move the script to replicated storage or replicated first or smth

calm finch
#

Alright ill move it to replicated storage

#

first

#

i mean

#

still doesnt work

#

thats strange

#

thats all that runs

smoky gyro
#

uhh

steep marten
#

you can just do player.character

#

its a property not a child

calm finch
#

oh ok

smoky gyro
#

mistype u got there

#

change

#

humanoid.died to

#

humanoid.Died

calm finch
#

mmm

#

where?

smoky gyro
#

and use :Connect

#

instead of :connect

#

wait ill fix it dor u

calm finch
#

local plr = game.Players.LocalPlayer
local character = plr:WaitForChild("Character")
local humanoid = character:WaitForChild("Humanoid")
local death = game.ReplicatedStorage.death

humanoid.Died:Connect(function()
game:GetService("ReplicatedStorage"):WaitForChild("death"):FireServer()
end)

#

os it here?

smoky gyro
#

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local deathEvent = ReplicatedStorage:WaitForChild("death")

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

humanoid.Died:Connect(function()
deathEvent:FireServer()
end)

#

this should work

steep marten
#

the way they had it was fine i think

smoky gyro
#

humanoid.died and :connect?

dry galleonBOT
#

studio** You are now Level 5! **studio

steep marten
#

no they have it properly spelled

#

am i tweaking

smoky gyro
#

yea i told him to

steep marten
#

i might be

#

im on a lot of drugs rn

smoky gyro
#

he fixed it before i did

steep marten
#

than mb

smoky gyro
#

but does it work now?

calm finch
#

Is the problem in the local script or the serverscript?

#

because local script calls the event

#

but it doesnt reset time

#

would you guys like me to record a video for you guys to

smoky gyro
#

do u have a remotevent?

calm finch
#

see?

smoky gyro
#

called death?

#

or Death

calm finch
#

yeah

smoky gyro
#

cuz capitals count

calm finch
#

death

steep marten
#

its death

#

the code should work

#

js try it

smoky gyro
#

place it startercharacterscripts

#

not in replicatedstorage

calm finch
#

heres the video

steep marten
#

bro you are not helpint

calm finch
#

you might find the problem here

steep marten
#

paste the local script ver batim

#

as it is rn

#

change line 7 to

#
local character = player.Character```
smoky gyro
#

ur local script bugin

steep marten
#

its bc they didnt update the character reference

#

other than that itll work

#

@calm finch

#

my work here is done

calm finch
#

ok

dry galleonBOT
#

studio** You are now Level 6! **studio

calm finch
#

thanks for helping

#

you to @smoky gyro thanks

smoky gyro
#

np

calm finch
#

it works!

#

only once tho Lol

#

ill try and fix it myself about the once part

steep marten
smoky gyro
#

instead u should do a function

steep marten
#

character is loaded whenever you respawn

#

thats the point

smoky gyro
#

yes, but the script is still connected to the old character

#

instead use a function and

player.CharacterAdded

#

would look something like this

#

local function characteraddstuff(character)
local humanoid = character:Waitforchild("Humanoid")
deathEvent:FireServer()
end)
end

if player.Character then
characteraddstuff(player.Character)
end

player.CharacterAdded:Connect(characteraddstuff)

dry galleonBOT
#

studio** You are now Level 6! **studio

smoky gyro
#

@calm finch

#

add that function in ur script and remove

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

before the function