So what I'm trying to do is have it to where the player touches a part, and audio will play inside of the player's gui. It all works find, but once started in player it says that line 9 is a nil value. Anyone know how to fix this?
local buttonPressed = false
function onTouch(hit)
if not buttonPressed then
buttonPressed = true
if hit.Parent:FindFirstChild("Humanoid") then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
if user then
local startui = user:FindFirstChild("PlayerGui")
if startui then
startui.StartRace:Play()
end
end
end
buttonPressed = false
end
end
script.Parent.Touched:connect(onTouch)
