I dont really get remove() but i see it on tycoons so i tried to make a buy button myself.
keeps saying WoodMine (the name of the item) is not a valid member of DataModel
any help?
script.Parent.Touched:connect(function(hit) local item = script.Parent.Parent.Item.Value if hit.Parent.Humanoid ~= nil then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Money.Value > script.Parent.Parent.Price.Value or player.leaderstats.Money.Value == script.Parent.Parent.Price.Value then game[item].Parent = script.Parent.Parent.Parent end end end)
game[item].Parent = script.Parent.Parent.Parent
It's probably because the WoodMine is not in the game, if it is in Workspace then you should put:
game.Workspace[item].Parent = script.Parent.Parent
Replace Workspace depending on where it is.
The problem is that WoodMine
isn't a member of DataModel
, as you said. DataModel
is the proper name for game
. DataModel
holds services only. So on line 6 of the code, you should change game
to where the model is being held, most likely in the Workspace
. Some code as to what I mean:
script.Parent.Touched:connect(function(hit) local item = script.Parent.Parent.Item.Value if hit.Parent.Humanoid ~= nil then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Money.Value >= script.Parent.Parent.Price.Value then -- Here I use the >= (greater than or equal to) operator. workspace[item].Parent = script.Parent.Parent.Parent end end end)