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

Sit and jump not true with script?

Asked by
Rdumb1 4
5 years ago
Edited by User#24403 5 years ago

I'm testing this script in humanoid were if the npc sits down with a baton, it would stand up with this script inside humanoid:

if script.Parent.Sit = true then
    script.Parent.Jump = true
end

I'm not sure if this is correct since I'm not an expert at scripting, and here's the sit script if you hit the humanoid with a baton.

function onTouched(hit)
    h = hit.Parent:findFirstChild("Humanoid")
    if h ~= nil then
        h.Sit = true
        h.Health = h.Health - 0
    end
end
script.Parent.Touched:connect(onTouched)


Edit; fixed indentation
0
And um.. They don't jump. Rdumb1 4 — 5y
0
they just sit down forever.. Rdumb1 4 — 5y

1 answer

Log in to vote
0
Answered by
danglt 185
5 years ago
Edited by User#24403 5 years ago

In this part of the script you need to use "==" to detect something or else it will think its trying to change something.

if script.Parent.Sit = true then
    script.Parent.Jump = true
end

Fixed Script (also its seeing if they jumped and if they jumped they jump again?)

if script.Parent.Sit == true then
    script.Parent.Jump = true
end
function onTouched(hit)
    local h = hit.Parent:findFirstChild("Humanoid")
    if h ~= nil then
        h.Sit = true
        h.Health = h.Health - 0
    end
end
script.Parent.Touched:connect(onTouched)

Fixed Script (you were trying to subtract nothing from the players health instead of killing them, btw if this doesent work then It could be because of of FE, the "h" is not finding the humanoid or both)

function onTouched(hit)
    h = hit.Parent:findFirstChild("Humanoid")
    if h ~= nil then
        h.Sit = true
        h.Health = 0
    end
end
script.Parent.Touched:connect(onTouched)

Accept if this helped! :D


Edit; also fixed indentation
Ad

Answer this question