You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I have a run script here, and I’m wondering how I would incorporate a stun value in this script. -
What is the issue? Include screenshots / videos if possible!
I’m not quite sure how to do it, as I’ve tried but it doesn’t work. (I removed the non working code from the local script you see down below) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried getting help from one of my friends, and I have looked on the devforum.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
My local script
BTW, I have another script that turns the player’s walkspeed and jumppower to 0 when stunned is true.
repeat task.wait() until game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
local Stunned = game.Players.LocalPlayer.Character.Values.Stun.Value
Stunned = false
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
local UserInputService = game:GetService("UserInputService")
local StarterPlayer = game:GetService("StarterPlayer")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local DefaultFieldOfView = 70
local DefaultWalkSpeed = 16
local SprintingFieldOfView = DefaultFieldOfView * 1.25
local SprintingWalkSpeed = DefaultWalkSpeed * 1.5
local Stamina = 100
local Sprinting = false
local TweeningTime = 0.3
local LastTaps = {
W = tick(),
A = tick(),
S = tick(),
D = tick()
}
local HoldingKeys = {}
Camera.FieldOfView = DefaultFieldOfView
Humanoid.WalkSpeed = DefaultWalkSpeed
UserInputService.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.W or Input.KeyCode == Enum.KeyCode.A or Input.KeyCode == Enum.KeyCode.S or Input.KeyCode == Enum.KeyCode.D then
if LastTaps[Input.KeyCode.Name] then
local TimeDistance = tick() - LastTaps[Input.KeyCode.Name]
LastTaps[Input.KeyCode.Name] = tick()
if TimeDistance <= 0.2 and not Sprinting then
Sprinting = true
TweenService:Create(Camera, TweenInfo.new(TweeningTime), {FieldOfView = SprintingFieldOfView}):Play()
Humanoid.WalkSpeed = SprintingWalkSpeed
end
end
end
if not table.find(HoldingKeys, Input.KeyCode.Name) then
table.insert(HoldingKeys, Input.KeyCode.Name)
end
end)
UserInputService.InputEnded:Connect(function(Input)
if table.find(HoldingKeys, Input.KeyCode.Name) then
table.remove(HoldingKeys, table.find(HoldingKeys, Input.KeyCode.Name))
end
if Input.KeyCode == Enum.KeyCode.W or Input.KeyCode == Enum.KeyCode.A or Input.KeyCode == Enum.KeyCode.S or Input.KeyCode == Enum.KeyCode.D then
local KeepSprinting = false
for Keycode, Value in pairs(LastTaps) do
if table.find(HoldingKeys, Keycode) then
KeepSprinting = true
break
end
end
if Sprinting and KeepSprinting == false then
Sprinting = false
TweenService:Create(Camera, TweenInfo.new(TweeningTime), {FieldOfView = DefaultFieldOfView}):Play()
Humanoid.WalkSpeed = DefaultWalkSpeed
end
end
end)
RunService.RenderStepped:Connect(function()
if Sprinting then
Stamina -= 0.25
else
Stamina += 0.25
end
Stamina = math.clamp(Stamina, 0, 100)
if Stamina <= 0 and Sprinting ~= false then
Sprinting = false
TweenService:Create(Camera, TweenInfo.new(TweeningTime), {FieldOfView = DefaultFieldOfView}):Play()
Humanoid.WalkSpeed = DefaultWalkSpeed
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
