Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a buy zone area that costs 100?

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?

1 comment

0

if leaderstats >= 100*

1 answer

✓ Accepted answer

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)

1 comment

0

Sorry if theres some bugs I'm on mobile and haven't tested it - hopefully it isn't too bad!

This discussion is preserved as it was. New answers, comments, and votes are closed.