As long as you stay disciplined and don’t forget how much effort you’ve already put in, I’m sure development will go just fine, even if it is slow. LMK when your game drops, can’t wait to play!
I really appreciate it, it certainly motivates me to proceed! I’ll be very happy to announce its release to you and thank you once more for helping me out and making this game possible.
Found it! For a split-second, the humanoid state is Landed
. Just tack this on to the conditional:
if humanoid.MoveDirection.Magnitude > 0 and humanoid:GetState() == Enum.HumanoidStateType.Running or humanoid:GetState() == Enum.HumanoidStateType.Landed
Hopefully this should fix it.
By the way, did the FloorMaterial
property not work? Surely we can just check if FloorMaterial
is not equal to nil or not equal to air.
I’ve tried FloorMaterial
twice. For some reason it doesn’t want to budge, I don’t know why. Maybe it’s a Roblox fault or maybe it’s a logical error (although unlikely because to me it logically made sense, but I can expect that maybe I missed something out)
I’ll try that and I’ll let you know how it went!
Oh yes, I remember we discussed this. I just have really poor memory , sorry!
Oh no you’re alright! I can understand why you’re talking about FloorMaterial
. I would’ve thought it’d make the most sense to use that property instead but Roblox decided that it’s not possible. Why? I don’t know but hey we’re trying workarounds!
Dangit. I think something else messed it up. It could be the jumping state. What are your thoughts?
It probably is the jumping state as well. I think I’m gonna hop into studio and find a new solution to this.
Alright! Do you want me to wait or should I also make it a condition with my current script? No rush of course, meanwhile I could work on something else!
Try making it a condition and see if that does anything. I’ll be done shortly.
Same problem. I would send you the video but it’s basically the same thing, there’s nothing new in the console.
OK! I figured it out. It’s because of Humanoid.Changed
/ Humanoid:GetPropertyChangedSignal
. If we think about this logically, if you continue to move in a direction at a fixed rate, the MoveDirection (and its magnitude) will not change. This means that it’s not going to be triggered, which is not what you want. So, we instead need to use another loop. A RunService loop is probably the best way to do this:
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
game:GetService("RunService").RenderStepped:Connect(function()
if hum.MoveDirection.Magnitude > 0 and hum.FloorMaterial ~= Enum.Material.Air then
print(hum.FloorMaterial)
end
end)
Don’t forget that you need to control the rate of VFX. RenderStepped fires basically once a frame, so you’re going to get rougly 60 VFX segments per frame. You could use another event to base this on, or you could use a delay system.
Okay! The script you have given me works, should I put the running part of the script inside the new code snippet you have given me?
Yep. Just replace what you had before with this, and add the VFX call where print(hum.FloorMaterial)
is.
AFK for a few minutes.
No worries take your time!
if humanoid.MoveDirection.Magnitude > 0 and humanoid.FloorMaterial then
game:GetService("RunService").RenderStepped:Connect(function()
if humanoid.MoveDirection.Magnitude > 0 and humanoid.FloorMaterial ~= Enum.Material.Air then
print(humanoid.FloorMaterial)
print("Person is running")
VFXController.Action("Run", true)
end
end)
else
print("Person stopped or in air")
print(humanoid:GetState())
VFXController.Action("Idle", false)
end
end)
Not sure if I did this right, because it made everything a lot more laggy. Sorry if I’m struggling to reason things out, I’m in an uncomfortable environment at the moment because I’m not in my room
On paper, yes! Let me know if there are any problems. Remember, you may wish to consider adding a delay.
Yeah, I figured because it’s a RunService Loop. Also, you’re running a loop inside a condition. You just want the RunService part on its own, not inside any other loops or conditions; sorry if I was vague with placement before.
Anyways, we can add a delay like so:
local db = true
game:GetService("RunService").RenderStepped:Connect(function()
if db and humanoid.MoveDirection.Magnitude > 0 and humanoid.FloorMaterial ~= Enum.Material.Air then
db = false
print(humanoid.FloorMaterial)
print("Person is running")
VFXController.Action("Run", true)
task.wait(0.5)
db = true
end
end)
I removed the else
statement because it triggers Idle()
, which only returns and does nothing.
Uh oh…
I can’t really tell what’s going on…
Is it lagging badly? Is it not accurately detecting if you’re running?
Can I see your full code again, btw?
Of course! Sorry for the video being vague. It’s only repeating the running every like… 0.6 seconds.
OnAction
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local root = char:WaitForChild("HumanoidRootPart")
local fallDistance
local VFXController = require(game:GetService("ReplicatedFirst").Modules.VFXController)
if humanoid and root then
local headHeight
humanoid.FreeFalling:Connect(function(state)
if state then
headHeight = root.Position.Y
elseif not state and headHeight ~= nil then
fallDistance = headHeight - root.Position.Y
--print("Fall distance: " .. fallDistance)
end
end)
end
humanoid.StateChanged:Connect(function(old, new)
if old == Enum.HumanoidStateType.Freefall and new == Enum.HumanoidStateType.Landed and fallDistance >= 22 then
local animation = script.Parent:WaitForChild("Animate").land.landAnim
local dance = humanoid:LoadAnimation(animation)
dance:Play()
VFXController.Action("Stomp", false)
task.wait(0.2)
end
end)
local isIdle = false
local db = true
game:GetService("RunService").RenderStepped:Connect(function()
if db and humanoid.MoveDirection.Magnitude > 0 and humanoid.FloorMaterial ~= Enum.Material.Air then
db = false
print(humanoid.FloorMaterial)
print("Person is running")
VFXController.Action("Run", true)
task.wait(0.5)
db = true
end
end)
VFXController
local VFX = {}
-- Variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Effects = ReplicatedStorage.VFX.Effects
local Actions = ReplicatedStorage.VFX.Actions
local UserRunning = false
-- Functions
-- When user stomps it activates the VFX related to it
local function Stomp()
local VFXFolder = Actions.Stomp
local InitialSize = Vector3.new(0.15, 1, 2.309)
for _, VFXContent in pairs(VFXFolder:GetChildren()) do
if VFXContent:isA("Model") and VFXContent.Name == "Triangles" then
local SparkEffect = Effects.Spark:Clone()
SparkEffect.Parent = Player.Character:WaitForChild("Torso")
local ModelClone = VFXContent:Clone()
ModelClone.Parent = workspace
ModelClone:MoveTo(Vector3.new(Player.Character:WaitForChild("Torso").Position.X, Player.Character:WaitForChild("Torso").Position.Y - 7, Player.Character:WaitForChild("Torso").Position.Z))
for _, VFXDescendant in pairs(ModelClone:GetChildren()) do
VFXDescendant.Size = InitialSize
local RandomSize = math.random(4, 8)
local ShowTween = TweenService:Create(VFXDescendant, TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {Size = Vector3.new(VFXDescendant.Size.X, RandomSize, VFXDescendant.Size.Z)})
ShowTween:Play()
SparkEffect.Enabled = true
end
task.wait(0.2)
for _, VFXDescendants in pairs(ModelClone:GetChildren()) do
local HideTween = TweenService:Create(VFXDescendants, TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {Size = Vector3.new(InitialSize)})
HideTween:Play()
SparkEffect:Destroy()
end
task.wait(0.1)
ModelClone:Destroy()
end
end
end
local funcRunning = false
-- When user runs it activates the VFX related to it
local function Run()
local VFXFolder = Actions.Run
if funcRunning then return end
funcRunning = true
for _, VFXContent in VFXFolder:GetChildren() do
local Leg = math.random(0,1)
local VFXDescendant = VFXContent:Clone()
if Leg == 0 then
VFXDescendant.Parent = game.Players.LocalPlayer.Character:WaitForChild("Left Leg")
VFXDescendant.Position = game.Players.LocalPlayer.Character:WaitForChild("Left Leg").Position
else
VFXDescendant.Parent = game.Players.LocalPlayer.Character:WaitForChild("Right Leg")
VFXDescendant.Position = game.Players.LocalPlayer.Character:WaitForChild("Right Leg").Position
end
local RunningTween = TweenService:Create(VFXDescendant, TweenInfo.new(0.4, Enum.EasingStyle.Quint), {Transparency = 1, Orientation = Vector3.new(math.random(0, 360),math.random(0, 360),math.random(0, 360))})
RunningTween:Play()
RunningTween.Completed:Connect(function()
VFXDescendant:Destroy()
end)
task.wait(0.1)
end
funcRunning = false
end
local function Idle(Condition)
return
end
-- On Fired
function VFX.Action(Action, isRunning)
UserRunning = isRunning
if Action == "Stomp" then
Stomp()
end
if Action == "Run" then
Run()
end
if Action == "Idle" then
Idle()
end
end
return VFX