Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Sit and jump not true with script?

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

2 comments

0

And um.. They don't jump.

0

they just sit down forever..

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.