Hello there i am new to scripting and trying out stuff.Hope you can help me!I had an old thread about this and figured I was not clear in how i explained the whole script and the problem.Anyways I created this HandTo Gui which is suppose to give tools from a person to another person.There is a textbox which you can insert the person name whom you want to give the item to.On default the tool that is given is the tool that you are equipping.
local script(1st gui)
local HandToGui = script.Parent
local Namebox = HandToGui.NameBox
local Givebutton = HandToGui.GiveButton
local HandToRemote = game.ReplicatedStorage.HandTo
local player = game.Players.LocalPlayer
local character = player.Character
Givebutton.MouseButton1Click:Connect(function()
if character:FindFirstChildWhichIsA("Tool") then
local tool = character:FindFirstChildWhichIsA("Tool")
print("yes this is a tool")
HandToRemote:FireServer(tool,Namebox.Text)
end
end)
local script(Popped up gui)
local frame = script.Parent
local Yes = frame.Yes
local No = frame.No
local Remote = game.ReplicatedStorage.HandTo2
local Value = frame.GivenBy
local Item = frame.Item
No.MouseButton1Click:Connect(function()
frame:Destroy()
end)
Yes.MouseButton1Click:Connect(function()
frame:Destroy()
Remote:FireServer(Value.Value,Item)
end)
server sided script
local HandToRemote = game.ReplicatedStorage.HandTo
local GivingFrame = game.ReplicatedStorage.GivingFrame
local HandToRemote2 = game.ReplicatedStorage.HandTo2
print("yeah this works")
local function GivingGui(plr,Tool,Name)
print(Tool.Name)
local gui = GivingFrame:Clone()
local Givenby = gui.GivenBy
local Item = gui.Item
gui.Label.Text = (plr.Name.." wants to give you "..Tool.Name.." is this the correct order?")
local player = game.Players:FindFirstChild(Name)
Givenby.Value = plr.Name
Item.Value = Tool.Name
gui.Parent = player.PlayerGui.MainGuis
end
local function GivingPointAndItem(plr,playr,Item)
local receiveplayer = game.Players:FindFirstChild(plr.Name)
local receivecharacter = game.Workspace:FindFirstChild(plr.Name)
local giveCharacter = game.Players:FindFirstChild(playr)
local receiveBackPack = receiveplayer:FindFirstChild("Backpack")
local Item = Item.Value
print(receiveplayer)
print(receivecharacter)
print(giveCharacter)
print(receiveBackPack)
print(Item)
print(plr.Name)
print(playr)
if giveCharacter:FindFirstChild(Item) == true then
print("1")
local tool = giveCharacter:FindFirstChild(Item)
tool.Parent = receiveBackPack
elseif plr.Backpack:FindFirstChild(Item) == true then
print("1")
local tool = plr.Backpack:FindFirstChild(Item)
tool.Parent = receiveBackPack
end
end
HandToRemote.OnServerEvent:Connect(GivingGui)
HandToRemote2.OnServerEvent:Connect(GivingPointAndItem)
Basically after everything is done.The server outputs everything except the number 1.Hope you can help!Thanks in advanced.
old thread: Item not changing parent - #10 by Azul_Cult