So I've just got into scripting and I am trying to make my first tycoon. I'm not sure how to assign the owner of the tycoon to a variable and call upon it when they make purchases. I have the leaderboard running, however whenever I try to put the "Owner" variable in place of my name it says that "Owner" is not a player. I've been looking for a solution for a few hours but I can't seem to find it. If I could find a fix to this it would solve all of my problems.
Here's the code I'm using now
local owner = game.workspace.tycoon.StartingScript
local function steppedOn2(part)
local player = part.Parent
if game.Players:GetPlayerFromCharacter(player) then
local player = game.getPlayerFromName(owner)
if game.Players.owner.leaderstats.Cash.Value >= 50 then
game.Players.owner.leaderstats.Cash.Value = game.Players.owner.leaderstats.Cash.Value - 50
Cannon.Parent = game.Workspace.Tycoon
CannonPad:Destroy()
end
end
end
CannonPad.Touched:connect(steppedOn2)
Thanks for the help

9 comments
correct
yep
Sorry, I accidentally posted what I was originally using. I've fixed it to call upon the variable used in the starting script
see if this works
also on the new script you posted owner is not used correctly, you'd have to use game.Players[owner.Value]
Thanks! This fixed my problem
Line 3 is unnecessary. Obviously it has a parent. Else the code couldn’t run since the part didn’t exist.
Yeah I realized that, my bad.
deleted