Stats not finding in the right folder

Hello. I am trying to make a portal because I am making a clicking game (I know you are going hate me now but I like these clicking games) And the stats is nil with the part in workspace

Script:

Is this a local script or server script?
You cannot access the LocalPlayer from the server.

If that script is a server script then your problem is LocalPlayer - you can only use LocalPlayer in a Local Script on the client side.
EDIT:
@deluc_t Beat me to it :smile:

1 Like

Serversided. Can that do anything?

EDIT:
turned to client and not working but no output messages.

That’s the problem.

You have to change the script to:

script.Parent.Touched:Connect(function(hit)
local player = hit.Parent:FindFirstChild("Humanoid")
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr.Stats.Coins.Value >= 200000 then -- Use the plr variable because you can access it from the server.
player.LowerTorso.CFrame = CFrame.new(-300.75, 9.058, 61.042)
end
end

Nothing is working and nothing is going into the output,

Do the coins show up in the player list?

The coins are hidden in the player list but my coins are 2M so should work.

try this

-- in a server script

script.Parent.Touched:Connect(function(brick)
   local plr = game.Players:GetPlayerFromCharacter(brick.Parent)

   if plr then -- check if the player exists
      local char = plr.Character or plr.CharacterAdded:Wait() -- get the character
      
      if plr.Stats.Coins.Value >= 200000 then
          char:SetPrimaryPartCFrame(CFrame.new(-300.75, 9.058, 61.042)) -- set the character's primary cframe
      end
   end
end)

Hmm, interesting.
Would this script work?

script.Parent.Touched:Connect(function(hit)
local player = hit.Parent:FindFirstChild("Humanoid")
if player then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr.leaderstats.Coins.Value >= 200000 then -- Use the plr variable because you can access it from the server.
player.LowerTorso.CFrame = CFrame.new(-300.75, 9.058, 61.042)
end
end
end

@HugeCoolboy2007 got it. Thank you for the help tho.

1 Like