I made a script whereas the player goes inside a part that has cancollide off and when the player enters it a value inside them gets changed, but i get this error whenever i go inside it, does anyone know why?
script.Parent.Touched:Connect(function(part)
local plr = game.Players:GetPlayerFromCharacter(part.Parent)
if plr:WaitForChild("PointMultiply").Value <= 1.1 then
plr:WaitForChild("PointMultiply").Value += 2
end
end)
Your script may be trying to infer the player from a part that is not actually part of the character model. For example, part.Parent could be another object that is not associated with a player.
You aren’t checking to see if what you are sending is actually a character model. Check for a humanoid in their character’s model before defining your variables. Should look something like this:
local Players = game:GetService("Players")
script.Parent.Touched:Connect(function(part)
local plr
if part.Parent:FindFirstChild("Humanoid") then
plr = Players:GetPlayerFromCharacter(part.Parent)
else
return warn("Player not found")
end
-- Continue code from here
end)