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

Why does this weld in studio but not in game?

I have two items that are to be welded, each are found in Lighting. The code works perfectly fine in studio, but when i go in game it gives an error.

Here's the code first;

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait();
local tank = game.Lighting.Tank:Clone()
tank.Parent = char
local weld = Instance.new("Weld",  char.Torso)
weld.Part0 = char.Torso
weld.Part1 = tank.Torso
weld.C0=CFrame.new(tank.Torso)
weld.C1=CFrame.new(char.Torso)

And here's the error; Torso is not a valid member of Model Script 'Players.doctortardiswho.Backpack.LocalScript', Line 5 Stack End

Would be nice if i could get an answer, if you need any more information please comment.

2 comments

0

Is the script a regular script or local script? If its a regular script try changing it to local

0

it is local.

1 answer

Try this:

local player = game.Players.LocalPlayer
repeat wait(.01) until player.Character
local char = player.Character
local tank = game.Lighting.Tank:Clone()
tank.Parent = char
local weld = Instance.new("Weld",  char.Torso)
weld.Part0 = char.Torso
weld.Part1 = tank.Torso
weld.C0=CFrame.new(tank.Torso.CFrame)
weld.C1=CFrame.new(char.Torso.CFrame)

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