How would I go about learning how to make Speed coils and traps and such? I am a bit confused and I don't really get how to make one, does one need to learn a lot of lua or is this something a beginner can learn?
Speed Coils
These are generally Tools
(although you could have a Part
that is then welded to the player) which will alter the WalkSpeed
(a property of Humanoid
) of the person who has one. Tools
need to be placed into the player's Backpack
so that they will be automatically parented to the player's Character
and become visible. One example of giving a Speed Coil would be:
game.Players.PlayerAdded:Connect(function(player) local coil = game.ServerStorage["Speed Coil"]:Clone() coil.Parent = player:WaitForChild("Backpack") end)
This assumes you have a Tool
inside the ServerStorage
named "Speed Coil"
the brackets indicate that the value inside is a child, but is required since the name of the "Speed Coil" contains a space.
Inside the "Speed Coil"'s Handle you could add a LocalScript with the following code to alter the player's speed
local tool = script.Parent.Parent tool.Equipped:Connect(function() local h = tool.Parent:FindFirstChild("Humanoid") if h ~= nil then h.WalkSpeed = 24 end end) tool.Unequipped:Connect(function() local h = tool.Parent:FindFirstChild("Humanoid") if h ~= nil then h.WalkSpeed = 16 end end)
These two functions take into account when the tool is equipped to the player and when it is not. The check for the humanoid is an optional precaution.
Traps
Kill Pad For a Part to kill a person, you can do one of two things, set the player to take damage (default Health is 100), or immediately set their health the zero.
Version 1: Take Damage ("KillPad" is a Part inside the Workspace)
workspace.KillPad.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid ~= nil then humanoid:TakeDamage(100) end end)
For a .Touched
event, the "hit" will refer to the part that touched the connected part, so we are looking for hit.Parent to be the player's Character
Version 2: Set Health ("KillPad" is a Part inside the Workspace)
workspace.KillPad.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid ~= nil then humanoid.Health = 0 end end)
These functions can be placed into Server Scripts or Local Scripts, but on the client, may not be seen by other players.
You can also use what is referred to as debounce
to prevent further Touch (or other) Events from Firing.
Below is an example of how this works
local debounce = true workspace.KillPad.Touched:Connect(function(hit) if debounce == false then return end debounce = false local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid ~= nil and humanoid.Health ~= 0 then humanoid.Health = 0 end debounce = true end)
While the debounce is pre-defined, we change its value for the purposes of the script, only when it's being run. By checking if the debounce is false after it has been changed, the script will return end until the function is carried out to completion. I also added a check on the humanoid's health here since there is no wait time on the script.
Regarding your question about difficulty: No, these kinds of scripts are not too difficult, you just need to make sure that each variable is clearly defined and you are able to recognize what properties or events can be used with certain variables. The Tool Events may be a bit complicated for beginners, if you dont understand how their parenting works, but the kill script is simple for early scripters since they learn how to manipulate the player with a basic setting.