Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

2 comments

0

It still isn't working....

0

Output?

This discussion is preserved as it was. New answers, comments, and votes are closed.