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

Why does this local script instantly kill the player upon loading it?

Asked by 7 years ago

This script works in ROBLOX Studio's test mode but not in the actual game. I have tried moving the models (containing the miniature torso) from the character into the workspace, which did not work. It is possible that the problem begins at line 61, since I have noticed that the welds after that code are not created.

local Player = game:GetService("Players").LocalPlayer
repeat wait() until Player and Player.Character

function Find(Owner,Name)
    return Owner:WaitForChild(Name)
end

local Debounce = false
local RightArm = Find(Player.Character, "Right Arm")
local LeftArm = Find(Player.Character, "Left Arm")
local Torso = Find(Player.Character, "Torso")

function rad(x)
    return math.rad(x)
end

local part = function(x,y,z,cc,name,an,tr,cframe,par)
    local x, y, z, cc, name, an, tr, cframe, par = x or 1, y or 1, z or 1, cc or false, name or '', an or false, tr or 0, cframe or nil, par or workspace
    local d = Instance.new'Part'
    d.Size = Vector3.new(x,y,z)
    d.CanCollide = cc
    d.Name = name
    d.Anchored = an
    d.Transparency = tr
    d.CFrame = cframe
    d.Parent = par
    return d
end

local weld = function(part0, part1, c0, par)
    local part0, part1, c0, part = part0 or nil, part1 or nil, c0 or CFrame.new(0,0,0), par or workspace
    local w = Instance.new("Weld")
    w.Part0 = part0
    w.Part1 = part1
    w.C0 = c0
    w.Parent = par
    return w
end

local YoyoR = part(2, .2, 2, false, "YoyoR", false, 0, CFrame.new(0,0,0), Player.Character)
local YoyoL = part(2, .2, 2, false, "YoyoL", false, 0, CFrame.new(0,0,0), Player.Character)

local YoyoRWeld = weld(RightArm, YoyoR, CFrame.new(.6,0,0)*CFrame.Angles(rad(80), rad(8), rad(-90)), RightArm)
local YoyoLWeld = weld(LeftArm, YoyoL, CFrame.new(-.6,0,0)*CFrame.Angles(rad(-100), rad(8), rad(90)), LeftArm)

local AttackYoyoR = part(2, .2, 2, false, "AttackYoyoR", true, 1, CFrame.new(0,0,0), Player.Character)
local AttackYoyoL = part(2, .2, 2, false, "AttackYoyoL", true, 1, CFrame.new(0,0,0), Player.Character)

local ModelR = Instance.new("Model")
ModelR.Parent = workspace
local ModelL = Instance.new("Model")
ModelL.Parent = workspace

local HumanoidR = Instance.new("Humanoid")
HumanoidR.Parent = ModelR
local HumanoidL = Instance.new("Humanoid")
HumanoidL.Parent = ModelL

local TorsoR = part(.2, .2, .2, false, "Torso", false, 1, CFrame.new(0,0,0), ModelR)
local TorsoL = part(.2, .2, .2, false, "Torso", false, 1, CFrame.new(0,0,0), ModelL)

local TorsoRWeld = weld(RightArm, TorsoR, CFrame.new(0, -1.3, 0), ModelR)
local TorsoLWeld = weld(LeftArm, TorsoL, CFrame.new(0, -1.3, 0), ModelL)


0
Since you used LocalPlayer, I'll assume this is in a LocalScript? If it's in a normal script, it will only work in test mode. Suamy 68 — 7y
0
Yes, this is a local script. MrN00bReaper 30 — 7y

Answer this question