Ok I am working on my game and I have everything set to be inv. until you buy the items.
I have a board in the floor that is the same way( board leads to basement).
I also have another board in the same spot so when that board is gone there isn't a hole in the floor.
but when you buy the board it comes back and leaves me 2 boards.
so I wrote a script that I placed in the button that says on hit make transparency = 1 and to make CanCollide = false ( for both boards.)
Now, the script that controls all of my upgrades and stuff is in the tycoon main folder.
and the button folder is a child of that.
I placed the script to make the boards transparent and stuff in the button itself. the button isn't working it does not change anything.
can someone help me fix it the right way please?
Button Script:
v.Head.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if v.Head.CanCollide == true then
if player ~= nil then
if script.Parent.Owner.Value == player then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.Health > 0 then
Script.Parent.FloorBoard.Transparency = 1
Script.Parent.FloorBoard.CanCollide = false
Script.Parent.Parent.Parent.Purchases.FloorBoard.Transparency = 1
Script.Parent.Parent.Parent.Purchases.FloorBoard.CanCollide = false
end
end
end
end
end
end
My PurchasHandeler script:
---handels all buttons
objects = {} ---empty erray for script
teamcolor = BrickColor.new(script.Parent.Name)
config = script.Parent.Parent.Parent.Configuration
wait(1)
script.Parent.Essentials.Spawn.TeamColor = teamcolor
script.Parent.Essentials.Spawn.BrickColor = teamcolor
script.Parent.Essentials.Collector.Touched:connect(function(hit)
if hit:FindFirstChild("Cash") then
script.Parent.Cash.Value = script.Parent.Cash.Value + hit.Cash.Value --checks if they ahve cash and takes the price from it
Instance.new("Sparkles",hit).Color=Color3.new(math.random(1,255)/255,math.random(1,255)/255,math.random(1,255)/255)
game.Debris:AddItem(hit,0.1)
end
end)
script.Parent.Essentials.Giver.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent) ---makes sure that is is a player
if player ~= nil then
if script.Parent.Owner.Value == player then ---makes sure that it is the owner
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.Health > 0 then ---makes sure thta the player is alive when touched
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)---checks the storage for cash
if cashmoney ~= nil then
cashmoney.Value = cashmoney.Value + script.Parent.Cash.Value
script.Parent.Cash.Value = 0 ----makes sure that they have enough money to buy the item
end
end
end
end
end
end)
script.Parent:WaitForChild("Buttons") ---- waits for all the buttons to arrive
for i,v in pairs(script.Parent.Buttons:GetChildren()) do
if v:FindFirstChild("Head") then ---makes sure it is a button
local object = script.Parent.Purchases:FindFirstChild(v.Object.Value)---look for an object by the name of the button
if object ~= nil then
objects[object.Name] = object:Clone() --- clones the object
object:Destroy() ----destroys the object
else
print("Button: "..v.Name.." is missing its object and has been removed.")
v.Head.CanCollide = false
v.Head.Transparency = 1 ---removes the button
end
if v:FindFirstChild("Dependency") then
v.Head.CanCollide = false
v.Head.Transparency = 1
coroutine.resume(coroutine.create(function()
if script.Parent.PurchasedObjects:WaitForChild(v.Dependency.Value) then
if config.ButtonFadeInDependency.Value == true then
for i=1,20 do
wait(config.ButtonFadeInTime.Value/20)
v.Head.Transparency = v.Head.Transparency - 0.05
end
end
v.Head.CanCollide = true
v.Head.Transparency = 0
end
end))
end
v.Head.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if v.Head.CanCollide == true then
if player ~= nil then
if script.Parent.Owner.Value == player then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.Health > 0 then
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
if cashmoney ~= nil then
if cashmoney.Value >= v.Price.Value then
cashmoney.Value = cashmoney.Value - v.Price.Value ---makes sure you have enough money
objects[v.Object.Value].Parent = script.Parent.PurchasedObjects ---makes the object go away until bought
if config.ButtonExplodeOnBuy.Value == true then
local explosion = Instance.new("Explosion",workspace)
explosion.Position = v.Head.Position
explosion.DestroyJointRadiusPercent = 0
explosion.BlastPressure = 0
end
if config.ButtonFadeOutOnBuy.Value == true then
v.Head.CanCollide = false
coroutine.resume(coroutine.create(function()
for i=1,20 do
wait(config.ButtonFadeOutTime.Value/20)
v.Head.Transparency = v.Head.Transparency + 0.05
end
end))
else
v.Head.CanCollide = false
v.Head.Transparency = 1
end
end
end
end
end
end
end
end
end)
end
end
Thanks!

3 comments
Have you ever tried using the Debounce?
no, i am new to all of this. i just started and i dont know what everything does, or how to use them yet lol
Look it up on the ROBLOX-Wiki, heres the link: http://wiki.roblox.com/index.php?title=Debounce