New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

Why does this weld in studio but not in game?

Asked by
hozann 75
3 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 682 — 3y
0
it is local. hozann 75 — 3y

1 answer

Log in to vote
-1
Answered by
Nidoxs 190
3 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