I have this script that adds the boolean value “onRed” to the player, however, when another script tries to access it, it just says "onRed is not part of model “Workspace.PANDASonNOOB”, however, it is very clear that onRed is parented to the player. What is the problem here?
btw i am accessing onRed a while after spawning, so it couldn’t be that onRed hasn’t been set yet
In my opinion, yes, you do have to put it in Players.Player. This might be happening because you created that value using a local script and you are trying to access the value from a server script.
Your script is looking in Workspace.PANDASonNOOB.
You also cut off the first letter in your screenshot, I can only see “nRed” in the image. Did you misspell onRed in the script?
local plr = script.Parent
local t = plr:WaitForChild("LowerTorso")
local player = game.Players:GetPlayerFromCharacter(plr)
local onRed = Instance.new("BoolValue", player)
onRed.Name = "onRed"
onRed.Value = false
script inside of part:
part = script.Parent
part.Touched:Connect(function(hit)
if not hit.Parent:FindFirstChildWhichIsA("Humanoid") == nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.onRed.Value = false
print(hit.Parent)
print(player.onRed.Value)
wait(0.1)
end
end)
part.TouchEnded:Connect(function(part)
if part.Parent:FindFirstChildWhichIsA("Humanoid") == nil then return end
local player = game.Players:GetPlayerFromCharacter(part.Parent)
player.onRed.Value = false
print(part.Parent)
print(player.onRed.Value)
end)