Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- game.Players.LocalPlayer.Chatted:Connect(function(msg)
- local cmd = msg:split(" ") -- split the word
- local prefix = "!" -- change your prefix here
- local afterprefix = "giveitem" -- name to call
- local Tool = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Tool") -- Find tool
- if cmd[1] == prefix..afterprefix and cmd[2] and Tool then -- check cmd , check is player is vaild and is player equipped tool
- local Found = {} -- List of player char
- for i,v in pairs(game.Players:GetPlayers()) do
- local name
- if cmd[3] == "true" then
- name = v.DisplayName
- else
- name = v.Name
- end
- if v ~= game.Players.LocalPlayer and cmd[2]:lower():sub(1,#name) == name:lower():sub(1,#name) then -- Confirm if name is 100% correct
- table.insert(Found,v.Character) -- insert player char
- break
- elseif v ~= game.Players.LocalPlayer and cmd[2]:lower():sub(1,#cmd[2]) == name:lower():sub(1,#cmd[2]) then
- table.insert(Found,v.Character)
- end
- end
- if #Found > 1 or #Found < 1 then -- Check if too many player cause sometime it maybe give wrong person
- return print("Error : Found too many players")
- end
- spawn(function()
- repeat
- game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = Found[1].HumanoidRootPart.CFrame -- goto player
- wait()
- until Tool.Parent ~= game.Players.LocalPlayer.Character -- Loop tp and stop when player is grab tool
- end)
- wait(.25)
- game.Players.LocalPlayer.Character.Humanoid:Destroy() -- delete your humanoid, i dont know why delete humanoid make other player can grab your equipped tool
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement