Hello there! Tommy here.
As you can see. I recently want to learn Roblox scripting. I decided to start learning with an easy script from Roblox studio Toolbox two days ago first. I dragged out a free model from it. It’s a trampoline! https://gyazo.com/bccc00a3af96e002a145413e168addff
The creator of the trampoline is EndorsedModel
So, it worked like this.
And, the script looks like this:
script.Parent.Touched:connect(function(obj)
local humanoid = obj.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.JumpPower = script.Parent.Parent.Configurations.JumpForce.Value
humanoid.Jump = true
wait(1)
humanoid.JumpPower = defaultJumpPower
end
end)
I already searched the APIs meaning on DevHub.
But, I still can’t figure it out. Sorry
I planned to post only once this kind of post about scripting.
In the future, I might not be going to post like kind of this again.
script.Parent.Touched:Connect(function(obj) -- This is a touched event, it fires when the part being defined was touched. The parameter "obj" is the object that touched this part.
local humanoid = obj.Parent:FindFirstChildWhichIsA("Humanoid") -- Defining where the humanoid is. If The "obj" is a part in the character, then it's model will have a Humanoid in it.
if humanoid then -- If we find a humanoid in obj.Parent then we know that a character touched this part instead of a random object.
humanoid.JumpPower = script.Parent.Parent.Configurations.JumpForce.Value -- Jumpower is a property of the Humanoid, it defines how high you can jump. You are setting the character's jump power to the value of a IntValue that is in a configuration's folder inside this model.
humanoid.Jump = true -- "Jump" is a property of the humanoid. If you set Jump to true, the character jumps.
wait(1) -- Waiting one second for the character to stop jumping.
humanoid.JumpPower = defaultJumpPower -- Setting the JumpPower to the value of a variable.
end -- Ending the if statement
end) -- Ending the function
Here you go! If you need any more clarification, feel free to ask.
Almost all stuff like that works without a capital, Destroy() doesnt need one, clone and connect, but it is a better habit to use capitals so you are right