Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can i script an owned tycoon?

Asked by 5 years ago
Edited 5 years ago

Error: 08:34:23.313 - Tycoon is not a valid member of Model

I made an owns tycoon but it works on roblox studio but not on the server. I will show you the script:

script.Parent.Touched:Connect(function()
    script.Parent.Parent.Parent["Nobody's Tycoon"].Name = game:GetService("Players").LocalPlayer.Name.. "'s Tycoon"
    local ownedtycoon = script:Destroy()
    if ownedtycoon then
        script.Parent.Parent.Parent["Nobody's Tycoon"].Name = script.Parent.Parent.Parent["Nobody's Tycoon"].Name
    end
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Rookie mistake.

script.Parent.Parent.Parent.Tycoon.Name = "Nobody's Tycoon"
local ownstycoon = script.Parent.Parent.Parent.Tycoon

The problem is that you named the Model Nobody's Tycoon right before you defined it, so it's not named Tycoon anymore. You need to define it by it's name so it'd look like this:

script.Parent.Parent.Parent.Tycoon.Name = "Nobody's Tycoon"
local ownstycoon = script.Parent.Parent.Parent["Nobody's Tycoon"]

But you could just make it look simpler and name ownstycoon after you define it:

local ownstycoon = script.Parent.Parent.Parent.Tycoon
ownstycoon.Name = "Nobody's Tycoon"
Ad

Answer this question