Skip to content

Commit 54b90f3

Browse files
authored
Update ServerScriptService.yaml
1 parent 10ef87b commit 54b90f3

File tree

1 file changed

+91
-63
lines changed

1 file changed

+91
-63
lines changed
Lines changed: 91 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,91 @@
1-
name: ServerScriptService
2-
type: class
3-
memory_category: Instances
4-
summary: |
5-
A container service for server-only `Class.Script` objects.
6-
description: |
7-
**ServerScriptService** is a container service for `Class.Script`,
8-
`Class.ModuleScript` and other scripting-related assets that are only meant
9-
for server use. The contents are never replicated to player clients at all,
10-
which allows for a secure storage of important game logic. Script objects will
11-
run if they are within this service and not
12-
`Class.BaseScript.Disabled|Disabled`.
13-
14-
This service houses just one property,
15-
`Class.ServerScriptService.LoadStringEnabled|LoadStringEnabled`, which
16-
determines whether the `loadstring` function in Luau is enabled. It's
17-
recommended to keep this disabled for security reasons, as misusing this
18-
function can lead to remote code execution vulnerabilities.
19-
20-
Scripts running in ServerScriptService may need access to various other assets
21-
which are not scripting-related, such as prefabricated models to be
22-
`Class.Instance:Clone()|cloned`. Such assets should go in
23-
`Class.ServerStorage`, which behaves similarly to this service except that
24-
`Class.Script` objects will not run even if they are not
25-
`Class.BaseScript.Disabled|Disabled`. Assets and `Class.ModuleScript` that are
26-
useful to both the server and clients should go in `Class.ReplicatedStorage`
27-
instead. Finally, you can further organize objects within this service through
28-
the use of `Class.Folder|Folders` without affecting the way it behaves.
29-
code_samples: []
30-
inherits:
31-
- Instance
32-
tags:
33-
- NotCreatable
34-
- Service
35-
- NotReplicated
36-
deprecation_message: ''
37-
properties:
38-
- name: ServerScriptService.LoadStringEnabled
39-
summary: |
40-
Toggles whether or not the `loadstring` function can be used by server
41-
scripts. Defaults to false.
42-
description: |
43-
Toggles whether or not the `loadstring` function can be used by server
44-
scripts. Defaults to false.
45-
code_samples: []
46-
type: boolean
47-
tags:
48-
- NotReplicated
49-
- NotScriptable
50-
deprecation_message: ''
51-
security:
52-
read: None
53-
write: None
54-
thread_safety: ReadSafe
55-
category: Behavior
56-
serialization:
57-
can_load: true
58-
can_save: true
59-
capabilities: []
60-
writeCapabilities: []
61-
methods: []
62-
events: []
63-
callbacks: []
1+
2+
3+
4+
-- Double Jump Script
5+
-- Place in a LocalScript in StarterPlayerScripts
6+
7+
local player = game.Players.LocalPlayer
8+
local character = player.Character or player.CharacterAdded:Wait()
9+
local humanoid = character:WaitForChild("Humanoid")
10+
11+
local userInputService = game:GetService("UserInputService")
12+
13+
-- Double jump variables
14+
local hasDoubleJumped = false
15+
local canDoubleJump = false
16+
local doubleJumpForce = 60
17+
18+
-- Function to perform double jump
19+
local function doubleJump()
20+
if canDoubleJump and not hasDoubleJumped then
21+
hasDoubleJumped = true
22+
23+
-- Apply upward force
24+
local rootPart = character:FindFirstChild("HumanoidRootPart")
25+
if rootPart then
26+
-- Stop any downward velocity first
27+
rootPart.Velocity = Vector3.new(rootPart.Velocity.X, 0, rootPart.Velocity.Z)
28+
-- Then apply upward force
29+
rootPart.Velocity = Vector3.new(rootPart.Velocity.X, doubleJumpForce, rootPart.Velocity.Z)
30+
31+
-- Optional: Add a particle effect for the double jump
32+
local jumpEffect = Instance.new("ParticleEmitter")
33+
jumpEffect.Texture = "rbxassetid://6101261295" -- Cloud particle
34+
jumpEffect.Size = NumberSequence.new(1.5)
35+
jumpEffect.Transparency = NumberSequence.new({
36+
NumberSequenceKeypoint.new(0, 0.5),
37+
NumberSequenceKeypoint.new(1, 1)
38+
})
39+
jumpEffect.Lifetime = NumberRange.new(0.3, 0.5)
40+
jumpEffect.Speed = NumberRange.new(5, 10)
41+
jumpEffect.Acceleration = Vector3.new(0, -10, 0)
42+
jumpEffect.SpreadAngle = Vector2.new(50, 50)
43+
jumpEffect.Rate = 50
44+
jumpEffect.Parent = rootPart
45+
46+
-- Remove the effect after a short time
47+
game:GetService("Debris"):AddItem(jumpEffect, 0.3)
48+
49+
print("Double jumped!")
50+
end
51+
end
52+
end
53+
54+
-- Track jumping and landing states
55+
humanoid.StateChanged:Connect(function(oldState, newState)
56+
if newState == Enum.HumanoidStateType.Jumping then
57+
canDoubleJump = true
58+
elseif newState == Enum.HumanoidStateType.Landed then
59+
canDoubleJump = false
60+
hasDoubleJumped = false
61+
end
62+
end)
63+
64+
-- Listen for jump input (Space key)
65+
userInputService.JumpRequest:Connect(function()
66+
if canDoubleJump and not hasDoubleJumped then
67+
-- The player is already in the air (first jump has occurred)
68+
-- Wait a tiny delay so this doesn't trigger immediately with the regular jump
69+
task.delay(0.1, doubleJump)
70+
end
71+
end)
72+
73+
-- Handle character respawning
74+
player.CharacterAdded:Connect(function(newCharacter)
75+
character = newCharacter
76+
humanoid = character:WaitForChild("Humanoid")
77+
hasDoubleJumped = false
78+
canDoubleJump = false
79+
80+
-- Re-connect the state change event
81+
humanoid.StateChanged:Connect(function(oldState, newState)
82+
if newState == Enum.HumanoidStateType.Jumping then
83+
canDoubleJump = true
84+
elseif newState == Enum.HumanoidStateType.Landed then
85+
canDoubleJump = false
86+
hasDoubleJumped = false
87+
end
88+
end)
89+
end)
90+
91+
print("Double jump script loaded! Jump twice to use.")

0 commit comments

Comments
 (0)