I'm trying to make a simulator game and I want to make a zone and you have to pay 100 cash. I am using this script right now:
local Player = game.Players.LocalPlayer
local leaderstats = game.ServerScriptService.Value.leaderstats.Cash
local Zone = game.Workspace.Zone
Zone.Touched:Connect(function(hit) if Player.leaderstats >= 100 then Zone.Transparency = 1 Zone.CanCollide = false end end)
For some reason, it doesnt work. Help?
Local scripts change things on the client (players computer only visible to them) Scripts change things on the server (which everyone can see)
I recommend having the "script" which checks of the player can afford the plot to be placed inside the Zone object.
local function getPlayerFromCharacter(character) for _, player in pairs(game:GetService("Players"):GetPlayers()) do if player.Character == character then return player end end end Zone.Touched:Connect(function(hit) If hit.parent.Humanoid then local player = getPlayerFromCharacter(hit.parent) if (the players leaderboard allows it) then --do your stuff end end end)