Problem with attribute

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
1 Like

are the parts being added to the game through scripts with that tag?

2 Likes

“Humanoid” is mispelled

Also the script has some redundant parts

fixed:

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
2 Likes

oh right didnt see it. lol

aaaaaaaaaaaaaaaaaaaaaaaa

1 Like

:man_facepalming:

Thanks lol, im so stupid :skull:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.