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 10 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

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

1 answer

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

Missing an end + misspelled Position on line 16.

repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character

local p = game.Players.LocalPlayer
local c = p.Character
local h = c:WaitForChild("Humanoid")
local storage = game.ReplicatedStorage["Folder"] --folder with items
local playerInventory = p.PlayerGui["inventory"] --Wherever you're putting the player's inventory

h.Died:connect(function()
    for i,v in pairs(playerInventory:GetChildren()) do
        if v:IsA("StringValue") then
            local storageItem = storage:findFirstChild(v.Value)
            if storageItem then
                print("Dropped "..v.Value)
                clo = storageItem:Clone()
                clo:MoveTo(c.Torso.Position + Vector3.new(math.random(-5,5),0,math.random(-5,5)))
                clo.Parent = Workspace
                end  
            end 
        end 
    end
end)
0
It still isn't working.... deputychicken 226 — 10y
0
Output? TheMyrco 375 — 10y
Ad

Answer this question