This was working perfectly fine until recently, but now it doesn't. I think I've found the issue, and that's that it doesn't find the player's character. I have no idea how to fix that because obviously every player has a character.
shopblock = script.Parent
shopdistance = 10
while true do
wait(.1)
for i,v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("Character") then
char = v:FindFirstChild("Character")
if char:FindFirstChild("Torso") then
torso = char:FindFirstChild("Torso")
if (shopblock.Position-torso.Position).magnitude <= shopdistance then
if not v.PlayerGui:FindFirstChild("raidershopgui") then
print("Cloning "..shopblock.Name.."gui to the player")
game.ReplicatedStorage[shopblock.Name.."gui"]:Clone().Parent = v.PlayerGui
end
elseif (shopblock.Position-torso.Position).magnitude > shopdistance and v.PlayerGui:FindFirstChild(shopblock.Name.."gui") then
v.PlayerGui[shopblock.Name.."gui"]:Destroy()
print("Destroyed "..shopblock.Name.."gui from the player")
end
end
end
end
end
Thanks for reading.

1 comment
Thanks. It worked!