What do you want to achieve?
For the GetPropertyChangedSignal to run everytime, not just twice and then that’s it.
What is the issue?
It seems to only run twice. I don’t know how and the script doesn’t get disabled or something.
What solutions have you tried so far?
I can get the script to run normal in studio but when ran in the ROBLOX player it only runs twice. There’s no documentation on how this happens.
local PlayersService = game:GetService("Players")
PlayersService.PlayerAdded:Connect(function(player)
warn(player)
player.CharacterAdded:Connect(function(character)
warn(character)
local Humanoid = character:WaitForChild("Humanoid")
local BoostedBy = nil
local BoostAmount = 0
Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
warn(Humanoid.FloorMaterial)
if Humanoid.FloorMaterial == Enum.Material.Cobblestone and BoostedBy ~= Humanoid.FloorMaterial then
BoostedBy = Enum.Material.Cobblestone
Humanoid.WalkSpeed -= BoostAmount
BoostAmount = 5
Humanoid.WalkSpeed += BoostAmount
elseif Humanoid.FloorMaterial == Enum.Material.Ground and BoostedBy ~= Humanoid.FloorMaterial then
BoostedBy = Enum.Material.Ground
Humanoid.WalkSpeed -= BoostAmount
BoostAmount = -Humanoid.WalkSpeed + 5
Humanoid.WalkSpeed = 5
else
Humanoid.WalkSpeed -= BoostAmount
BoostAmount = 0
BoostedBy = nil
end
end)
end)
end)
That’s the thing. The property is changing. Humanoid.FloorMaterial is constantly changed to the material under the player, and if you use a while loop, you can get the same result except it actually works.
Using a while loop, You can prove it changes and that the function isn’t firing.
code to generate materials for testing if you want it
local model = Instance.new("Model")
model.Name = "Materials"
model.Parent = game.Workspace
for index, material in Enum.Material:GetEnumItems() do
local part = Instance.new("Part")
part.Material = material
part.Size = Vector3.new(6,.5,6)
part.Anchored = true
local x = (index-1) % 6
local y = math.floor((index-1) / 6)
part.CFrame = CFrame.new(x*6, 10, y*6)
part.Parent = model
end
Where is your script located? What materials are you walking on? Is anything else in the environment changing? Does your script work in other games or on an empty baseplate?