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

Hiya! I was wondering how death functions and teleportation work with models and not tools?

Asked by 11 years ago

I had someone answer my last question on it, with a script, but their script doesn't work for some reason, I think it was because they put handle.Cframe, and there isnt a handle... anyway, i was wondering if someone could teach me about teleportation when a person dies, here is the script :D

01repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character
02local p = game.Players.LocalPlayer
03local c = p.Character
04local h = c:WaitForChild("Humanoid")
05local storage = game.ReplicatedStorage["Folder"] --folder with items
06local playerInventory = p.PlayerGui["inventory"] --Wherever you're putting the player's inventory
07h.Died:connect(function()
08    for i,v in pairs(playerInventory:GetChildren()) do
09    if v:IsA("StringValue") then
10        local storageItem = storage:findFirstChild(v.Value)
11        if storageItem then
12            print("Dropped "..v.Value)
13            clo = storageItem:Clone()
14            clo:MoveTo(c.Torso.Positon + Vector3.new(math.random(-5,5),0,math.random(-5,5)))
15            clo.Parent = Workspace
16end  end end end)

1 answer

Log in to vote
0
Answered by
TheMyrco 375 Moderation Voter
11 years ago

Missing an end + misspelled Position on line 16.

01repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character
02 
03local p = game.Players.LocalPlayer
04local c = p.Character
05local h = c:WaitForChild("Humanoid")
06local storage = game.ReplicatedStorage["Folder"] --folder with items
07local playerInventory = p.PlayerGui["inventory"] --Wherever you're putting the player's inventory
08 
09h.Died:connect(function()
10    for i,v in pairs(playerInventory:GetChildren()) do
11        if v:IsA("StringValue") then
12            local storageItem = storage:findFirstChild(v.Value)
13            if storageItem then
14                print("Dropped "..v.Value)
15                clo = storageItem:Clone()
View all 22 lines...
0
It still isn't working.... deputychicken 226 — 11y
0
Output? TheMyrco 375 — 11y
Ad

Answer this question