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

Having trouble creating sit script for a slide?

Asked by
ghaybe 5
6 years ago

Hello, I'm adding a slide in a game I'm creating, and so that the players slide, I'm adding a sit script. I've been having trouble creating a working script - can anyone help? Thank you!

1
You have a valkyrie and you’re this immature...I'd expect more from a trader like you. User#19524 175 — 6y

3 answers

Log in to vote
0
Answered by
AIphanium 124
6 years ago
Edited 6 years ago

Its quite simple! Thanks to the Humanoid, you can make everyone who touches a part sit!

Carefully, read.

part = script.Parent -- THIS, is the location of the part, which trying to find the part that activates the function.
part.Touched:Connect(function(hit) -- The function! it detects if the part is touched!
if hit.Parent:FindFirstChild("Humanoid") then -- Detects if there is a humanoid!
hit.Parent.Humanoid.Sit = true -- Activates an option inside humanoid!
else
return
end
end)

Thanks for reading!

Have a nice day!

-- One more thing, at the first line, make sure to give CORRECT locations, and try to create an Invisible Part with CanCollide off at the place you want the player to sit.

(Sorry if it doesn't works, didn't check on Studio)

--- Special Note To Down Voters : Please comment your Reason, And do not hide. ---

0
Thank you very much! I'll test it on studio right now and let you know! :) ghaybe 5 — 6y
0
No problem! AIphanium 124 — 6y
Ad
Log in to vote
0
Answered by
amanda 1059 Moderation Voter
6 years ago

Inside the Humanoid, there is a property called Sit which can be toggled to make the associated Character sit.

What you should likely do, is at the top of the slide have a Part that when Touched:

  • checks if what Touched it is associated with a Player
  • get their Character's Humanoid
  • set the Humanoid's Sit property to true
Log in to vote
0
Answered by 6 years ago

Although it's already been answered, I'll leave my answer here just as a 'masterclass' about this.

Inside Humanoids there is a sit property which lets you easily make any Humanoid sit.

The script works a little something like this. Read carefully as I added comments to make sure you get what's happening! :)

part = script.Parent -- this identifies the parent of the script aka the block we are using to make someone sit. You can change this to any part, for example game.Workspace.Baseplate to make the baseplate the part

part.Touched:Connect(function(hit) -- this is the function that tells us when the part is touched
    print 'initialized' -- this is purely something I like to do for debugging, it tells us that the function has started by printing to the console

    if hit.Parent:FindFirstChild("Humanoid") then -- this makes sure the object hitting it was a humanoid, or else it would fire for anything
        hit.Parent.Humanoid.Sit = true -- makes our user sit
    else
        print 'ended'
    end
end)

There we have it, I hope this helped you out! :)

Answer this question