local plyr = game.Players:FindFirstChild(game.Workspace.Goals.SoccerBall.Kicker.Value) game.Workspace.Goals.SoccerBall.Kicker.Changed:connect(function() script.Parent.Parent.goalmusic.SoundId = "rbxassetid://" .. plyr.hiddenstats.Value.Value end)
if a player touches the soccer ball his name goes on the Kicker.Value (this works) I use the Kicker.Value to find the player using game.Players:FindFirstChild(game.Workspace.Goals.SoccerBall.Kicker.Value) then I initiate the function after the Kicker.Value is changed then I make the script.Parent.Parent.GoalMusic.SoundID equal to the hidden stats.Value.Value of the player who just kicked the soccer ball
did I do anything wrong?
You're defining plr
before the actual Changed event. It looks like you want to get the player from the value every time the value changes, but instead you're getting whatever the value starts as.
local kicker=workspace.Goals.SoccerBall.Kicker kicker.Changed:connect(function() script.Parent.Parent.goalmusic.SoundId="rbxassetid://"..game.Players:FindFirstChild(kicker.Value).hiddenstats.Value.Value end)