Heya! I’m attempting to make a script that detects when a part with the tag of “SpeedModifier” change the players speed based on the parts attribute(“SpeedAmplifierValue”)'s value. But nothings happening and there are no errors in the output, please help. Thanks!
local CollectionService = game:GetService("CollectionService")
for _, RaceTrack in CollectionService:GetTagged("SpeedModifier") do
if RaceTrack:GetAttribute("SpeedAmplifierValue") then
RaceTrack.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanod") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
Player.Character.Humanoid.WalkSpeed = RaceTrack:GetAttribute("SpeedAmplifierValue")
end
end)
end
end
local CollectionService = game:GetService("CollectionService")
for _, RaceTrack in CollectionService:GetTagged("SpeedModifier") do
if RaceTrack:GetAttribute("SpeedAmplifierValue") then
RaceTrack.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
char.Humanoid.WalkSpeed = RaceTrack:GetAttribute("SpeedAmplifierValue")
end
end)
end
end