Before you ask, it is not that simple, and the naming is correct
I am making a fabulous tycoon game, and I am working on one of the main scripts which handles all the buttons. Here is the part that I believe is important for this topic:
local ObjectLink = Button.Properties["Object Link"].Value
local ObjectLinkPrevParent = ObjectLink.Parent
local ObjectLinkPrevName = ObjectLink.Name
ObjectLink.Name = HttpService:GenerateGUID(false)
ObjectLink.Parent = game.ReplicatedStorage.Tycoons.tmp
for _, Following in Button.Properties.Following:GetChildren() do
local ButtonID = tonumber(Following.Name)
local ButtonObject = Buttons[tostring(ButtonID)]
local ButtonObjectPrevParent = ButtonObject.Parent
local ButtonGUID = HttpService:GenerateGUID(false)
ButtonObject.Name = ButtonGUID
ButtonObject.Parent = game.ReplicatedStorage.Tycoons.tmp
Button.Structure.Head.Touched:Connect(function(hit)
local Player: Player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Date = DateTime.now():ToLocalTime()
if Tycoon:GetAttribute("Owner") == tostring(Player.UserId) and Data.Currencies.Cash >= Button.Properties.Cost.Value then
local dt = DateTime.now()
Data.Tycoon.Floors[Floor.Name].Buttons[Button.Name] = {
Time = {
["Date and time"] = {
Time = {
Second = dt:FormatUniversalTime("s", "en-us"),
Minute = dt:FormatUniversalTime("m", "en-us"),
Hour = dt:FormatUniversalTime("H", "en-us")
},
Date = {
["Day"] = dt:FormatUniversalTime("D", "en-us"),
Month = dt:FormatUniversalTime("M", "en-us"),
Year = dt:FormatUniversalTime("YYYY", "en-us")
}
},
},
ID = Button.Name
}
ObjectLink.Name = ObjectLinkPrevName
ObjectLink.Parent = ObjectLinkPrevParent
ButtonObject.Parent = ButtonObjectPrevParent
ButtonObject.Name = tostring(ButtonID)
Button:Destroy()
end
end)
end
else
Button:Destroy()
end
end
end
Full Script
local Buttons
local Tycoon = script.Parent.Parent.Parent
local HttpService = game:GetService("HttpService")
local PlayerDataService = require(game.ServerScriptService.Data["Player Data"])
for _, Object in Tycoon.Objects:GetDescendants() do
if Object.Name == "Owner Part" and Object.Parent.Name == "Door" and Object.Parent.Parent.Name == "Main" and Object:IsA("BasePart") then
Object.Touched:Wait()
end
end
task.wait(0.5)
local Player = game.Players:GetPlayerByUserId(tonumber(Tycoon:GetAttribute("Owner")))
local Data = PlayerDataService.GetData(Player)
for _, Floor in pairs(Tycoon.Objects.Floors:GetChildren()) do
for _, Button in pairs(Floor.Purchased.Buttons:GetChildren()) do
if Data.Tycoon.Floors[Floor.Name].Buttons[Button.Name] == nil or Data.Tycoon.Floors[Floor.Name].Buttons[Button.Name].ID == nil or Data.Tycoon.Floors[Floor.Name].Buttons[Button.Name].ID ~= Button.Name then
Buttons = Tycoon.Objects.Floors[Floor.Name].Purchased.Buttons
if Button:IsA("Script") then continue end
--Properties
local ButtonName = Button.Properties["Object Name"].Value
local ButtonCost = Button.Properties.Cost.Value
local ButtonBillboardFrame = Button.Structure.Head.BillboardGui.Area
ButtonBillboardFrame["Object Name"].Text = tostring(ButtonName)
ButtonBillboardFrame["Price Tag"].Text = "$"..ButtonCost
if Button.Properties["Cash Generator"].Value == false then
Button.Structure.Head.Color = Color3.new(1, 0, 0)
else
Button.Structure.Head.Color = Color3.new(0, 1, 0)
end
--Functionality
local ObjectLink = Button.Properties["Object Link"].Value
local ObjectLinkPrevParent = ObjectLink.Parent
local ObjectLinkPrevName = ObjectLink.Name
ObjectLink.Name = HttpService:GenerateGUID(false)
ObjectLink.Parent = game.ReplicatedStorage.Tycoons.tmp
for _, Following in Button.Properties.Following:GetChildren() do
local ButtonID = tonumber(Following.Name)
local ButtonObject = Buttons[tostring(ButtonID)]
local ButtonObjectPrevParent = ButtonObject.Parent
local ButtonGUID = HttpService:GenerateGUID(false)
ButtonObject.Name = ButtonGUID
ButtonObject.Parent = game.ReplicatedStorage.Tycoons.tmp
Button.Structure.Head.Touched:Connect(function(hit)
local Player: Player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Date = DateTime.now():ToLocalTime()
if Tycoon:GetAttribute("Owner") == tostring(Player.UserId) and Data.Currencies.Cash >= Button.Properties.Cost.Value then
local dt = DateTime.now()
Data.Tycoon.Floors[Floor.Name].Buttons[Button.Name] = {
Time = {
["Date and time"] = {
Time = {
Second = dt:FormatUniversalTime("s", "en-us"),
Minute = dt:FormatUniversalTime("m", "en-us"),
Hour = dt:FormatUniversalTime("H", "en-us")
},
Date = {
["Day"] = dt:FormatUniversalTime("D", "en-us"),
Month = dt:FormatUniversalTime("M", "en-us"),
Year = dt:FormatUniversalTime("YYYY", "en-us")
}
},
},
ID = Button.Name
}
ObjectLink.Name = ObjectLinkPrevName
ObjectLink.Parent = ObjectLinkPrevParent
ButtonObject.Parent = ButtonObjectPrevParent
ButtonObject.Name = tostring(ButtonID)
Button:Destroy()
end
end)
end
else
Button:Destroy()
end
end
end
Quite a mess I know
On this line,
if Tycoon:GetAttribute(“Owner”) == tostring(Player.UserId) and Data.Currencies.Cash >= Button.Properties.Cost.Value then
An error appears with the message
13:12:27.572 Properties is not a valid member of Model “1” - Server - Button Executor:54
It happens on specific buttons when I purchase them
Here is a video to understand better:
Sorry for being laggy
In my game, each button has a folder named “Following” inside a folder called “Properties”. In the Following folder, there are RayValues, whose only purpose is to define which button continues after the other. In the case of the button I pressed on my video, there are two values inside, one for the dropper and one for the dropper walls. This starts a chain reaction since the wall button and the dropper have the following ones.
For some reason, when I pressed the button, only one appeared, and the other one was missing.
Please don’t hesitate posting.