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

HandTo GUI is freezing my hand once I give the item, how would I fix this?

Asked by 5 years ago

So basically this is a script in my hand to gui (parts of the code taken from multiple other scripts created by different people) but whenever I hand something it freezes my hand in the position that the item was in. For example, if I was holding a cup and I use the give GUI, it will give it to the player but my hand will stay frozen pointing outwards. I tried using UnequipTools on line 18 but it says UnequipTools is not a valid member of model. How would I fix this? If you need the code for the part where a script picks up the remoteevent let me know and I'll add it.

script.Parent.commands.give.FocusLost:connect(function(enterPressed)
    if enterPressed then
        local count = 0
        local plr = nil
        for i,v in next, game.Players:GetChildren() do
            if string.len(v.Name) >= string.len(script.Parent.commands.give.Text) then
                if string.lower(script.Parent.commands.give.Text) == string.lower(string.sub(v.Name,0,string.len(script.Parent.commands.give.Text))) then
                    count = count+1
                    plr = v
                end
            end
        end
        if count == 1 and game.Players.LocalPlayer.Name ~= plr.Name then
            local item = nil
            for i,v in next, game.Players.LocalPlayer.Character:GetChildren() do
                if v.ClassName == "Tool" then
                    item = v
                    game.Players.LocalPlayer.Character:UnequipTools()
                end
            end
            if item ~= nil then
                game.Workspace.GiveSystem.GiveItem:FireServer(plr,item)
            end
            script.Parent.commands.give.Text = "Item Given!"
            wait(0.5)
            local hgui = script.Parent
            hgui:Destroy()
        end
    end
end)

Thanks, TypicallyPacific

0
line 22 you dont have to pass the player Imperialy 149 — 5y
0
I don't think that will fix the problem of the hand freezing as it's just passing info along. TypicallyPacific 61 — 5y

Answer this question