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

How can I make a script repeat on death?

Asked by 4 years ago
Edited 4 years ago

I have two scripts I would like to repeat on death because the will automatically stop working on death

local InputService = game:GetService("UserInputService") local Players = game:GetService("Players")

local client = Players.LocalPlayer local backpack = client:WaitForChild("Backpack") local character = client.Character or client.CharacterAdded:Wait()

local tools = backpack:GetChildren() local toolIndex = 1

local function add(v, x) return v + (x or 1) end

local function sub(v, x) return v - (x or 1) end

local function unequipTools() for _, item in next, character:GetChildren() do if item:IsA("Tool") then item.Parent = backpack end end end

local function mouseScrolled(dir) local numTools = #tools unequipTools()

toolIndex = dir and add(toolIndex) or sub(toolIndex)


toolIndex = toolIndex < 1 and numTools or toolIndex > numTools and 1 or toolIndex


local tool = tools[toolIndex] 
tool.Parent = character

end

InputService.InputChanged:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseWheel then mouseScrolled(input.Position.Z > 0) end end)

and

local player = game.Players.LocalPlayer

player.CameraMode = Enum.CameraMode.LockFirstPerson

0
also how do you get the view source for scripts imperialsnoop377 5 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The CharacterAdded event fires when a player's character spawns (or respawns).

also how do you get the view source for scripts

To help with malicious intentions this feature was removed from roblox.

Ad

Answer this question