Need help with Claiming a tyccon

Hello,
I want to make a claim tycoon system.

This is the code I have so far.
Client Script:

local ProximityPromptService = game:GetService("ProximityPromptService")
local Rep = game:GetService("ReplicatedStorage")
local Events = Rep:WaitForChild("Events")
local Claim = Events.Claim

-- Detect when prompt is triggered
local function onPromptTriggered(promptObject, player)
	
end

How would I do this with a remote function

Basically Have the client request a free tycoon for owner ship, the server checks to see if the client already has a tycoon and if they don’t returns ownership to the client

You add a string value named owner which will have the value name of the owner then if another person came to claim it the server will check if there is a string value if there is then return end

Im thinking of a bool value inserted into the client

I mean

You could just simply Disable the Prompt when a player first triggers it on the server, or you can use ObjectValues which check if the Player Object is equal to the Original Owner who first activated the prompt

Yeah, for some reason the prompt is not working, like its not showing up when I walk close to it

dd d

Don’t tell me you have a LocalScript on the Server

Try setting the require line of sight to false
Also don’t use local script for that as local script only works when parented to starter player or starter character or starter gui

No, I don’t lol thats a local script in the workspace

THAT’S THE SAME THING :neutral_face: LocalScripts can’t run on the workspace either

Oh, where do I put this then xD

You can put it in starter character or starter player or even starter GUi as I said above it will work

Reference the LocalScript inside StarterPlayerScripts, then you could either use a RemoteEvent or RemoteFunction to handle this (Preferably I’d do RemoteEvent to make it easier)

local ProximityPromptService = game:GetService("ProximityPromptService")
local Rep = game:GetService("ReplicatedStorage")
local Events = Rep:WaitForChild("Events")
local Claim = Events.Claim

-- Detect when prompt is triggered
local function onPromptTriggered(promptObject, player)
	Claim:FireServer()
end

And on your server side:

local Rep = game:GetService("ReplicatedStorage")
local Events = Rep:WaitForChild("Events")
local Claim = Events.Claim
local CurrentOwner

Claim.OnServerEvent:Connect(function(Player)
    print(CurrentOwner)
    if CurrentOwner == nil then
        CurrentOwner = Player
        --Do your tycoon stuff here, aka disabling the prompt on the server side
    end
end)

Can you try unticking the RequiresLineOfSight? That should fix it if it’s not showing when you walk up to it.

1 Like