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

How To Run The Click & Selected Functions When textbutton Is Clicked?

Asked by 6 years ago
Edited 6 years ago

So I have spent a great deal of time working on perfecting this tool. Now I am wanting to change it so that the same effect of the tool. How can I easily convert the functions so that the rest of the script is triggered when the TextButton is clicked?

local frame = script.Parent.Parent.Parent:WaitForChild('Items')
script.Parent.MouseButton1Click:connect(function()
frame.Visible = not frame.Visible
end)

tool = script.Parent
grid = 3
grid2 = 6


function click(mouse)  --- This line and below are what I need to know how to convert
    local Spawn = game.Workspace.start
    local Pos =(Vector3.new((mouse.Hit.p.X+grid) - (mouse.Hit.p.X+grid)%grid2, (Spawn.Position.Y+0.5), (mouse.Hit.p.Z+grid) - (mouse.Hit.p.Z+grid)%grid2)) --tree stump
    local part = game.ReplicatedStorage.Table:Clone()
    part.Position = Pos
    part.Parent = game.Workspace
    print("Tree Placed")
end

function selected(mouse)
    mouse.Button1Down:connect(function () click(mouse) end)
    wait(2)
end

tool.Equipped:connect(selected)
0
you mean running the click and selected functions when the textbutton (Script.Parent)? is clicked?? RobloxianDestory 262 — 6y
0
Yes BunnyFilms1 297 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

put click() and selected() inside

script.Parent.MouseButton1Click:Connect(function()
frame.Visible = not frame.Visible
end)

like

script.Parent.MouseButton1Click:Connect(function()
frame.Visible = not frame.Visible
click()
selected()
end)
Ad

Answer this question