0

Will you help me with my GUI tool giver script?

Japhie 20
7 years ago

This is what I've tried:

local Tool = game.Lighting.Tool
local player = game.Players.LocalPlayer

function onClick()
game.Workspace[player.Name].Torso.CFrame = CFrame.new(Vector3.new(0, 5, 0))
if script.Parent.Visible == true then
script.Parent.Parent:Destroy()
end
end

function Give(player)
Tool1 = Tool:clone()
Tool1.Parent = player.Backpack
end

script.Parent.MouseButton1Click:connect(onClick)
script.Parent.MouseButton1Click:connect(Give)


This is in a regular script. Im teleporting correctly and the gui dissappears but I want it to give me a tool when I click the textbutton. And that is not working D: Currently the tool is located under Lighting but I'm not quite sure if that's where it should be. I'm also concerned about:

script.Parent.MouseButton1Click:connect(Give)


0
local Tool = game.Lighting.Tool
local player = game.Players.LocalPlayer

function onClick()
player.Character.Torso.CFrame = CFrame.new(Vector3.new(0, 5, 0))
Tool1 = Tool:clone()
Tool1.Parent = player.Backpack
if script.Parent.Visible == true then
script.Parent.Parent:Destroy()
end
end

script.Parent.MouseButton1Down:connect(onClick)



A couple of things. First, LocalPlayer only works if it's in a local script. Second, you don't need two functions for the two things. I merged them both into one function. Third, player.Character is more efficient to use, it's the same thing but I prefer to use it. Finally, I use MouseButton1Down, rather then MouseButton1Click.

Hope this helps!

0
Thanks so much :D Japhie 20 — 7y
0
Tool1 = Tool:clone()

Tool = Tool:clone()