Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

kill for money script is not working? (tried everything i could think of)

Asked by 4 years ago
Edited 4 years ago

I've been trying for days to get this kill for money script. I've basically tried almost everything i could think of like put the script into the zombie humanoid leave it out of the zombie.I really don't know what to do at this point so i came here to see if anybody can help me with it.

local Humanoid = script.Parent.Zombie 
function PwntX_X() 
local tag = Humanoid:findFirstChild("creator") 
if tag ~= nil then 
if tag.Value ~= nil then 
local Leaderstats = tag.Value:findFirstChild("leaderstats") 
if Leaderstats ~= nil then 
Leaderstats.Cash.Value = Leaderstats.Cash.Value + 7 --Change Money to the stat that is increased. 
wait(0.1) 
script:remove() 
end 
end 
end 
end 
Humanoid.Died:connect(PwntX_X) 

(by the way i'm making a zombie game if you can't already tell)

0
Please use code blocks (The blue button on the right side of the top left icons (B, i, >, globe, C, Lua)). Nowaha 459 — 4y
0
oh mb CamCIutch 4 — 4y

1 answer

Log in to vote
0
Answered by
Nowaha 459 Moderation Voter
4 years ago
Edited 4 years ago

First of all, you're using script:remove(), which is deprecated; that means that it shouldn't and in the future can't be used anymore. Instead, use script:Destroy()

You should also capitalize the first letters in Destroy, FindFirstChild, Connect.

Instead of all the if's, you can just use :WaitForChild() instead of FindFirstChild(). This will cause the script to stop if it can't find it, and thus you do not need the if statements.

I've fixed your code for you, let me know how it runs:

local Humanoid = script.Parent.Zombie ;

Humanoid.Died:Connect(function() 
    local tagValue = Humanoid:WaitForChild("creator").Value;
    local leaderstats = tagValue:WaitForChild("leaderstats");
    leaderstats.Cash.Value = leaderstats.Cash.Value + 7;
    wait(0.1);
    script:Destroy();
end);
0
*what* does not work? Nowaha 459 — 4y
0
it works its just the weapons im using thanks alot! CamCIutch 4 — 4y
Ad

Answer this question