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

Why does this weld in studio but not in game?

Asked by
hozann 75
8 years ago

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.

0
Is the script a regular script or local script? If its a regular script try changing it to local Prioxis 673 — 8y
0
it is local. hozann 75 — 8y

1 answer

Log in to vote
-1
Answered by
Nidoxs 190
8 years ago

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)

Ad

Answer this question