WeldConstraint not working

I’m trying to make a HotPotato gamemode in a Color Coding game, but I can’t weld a bomb model’s primarypart 2 studs in front of a random player’s root.


function HotPotato:WeldBomb(bomb,root)
	local weld = Instance.new("WeldConstraint")
	weld.Part0 = bomb.Bomb
	weld.Part1 = root
	weld.Name = "HotPotatoWeld"
	weld.Parent = bomb
	return weld
end

The line attempting to weld Part0 fails with the error “Bomb is not a valid member of Player “Players.Violet_sheer”” even though “bomb” is the bomb model.

I’m trying to a weld a part from the inside of a model to a player’s root part. Is that possible?

1 Like

Also whenever I try to manually adjust the weld in test mode, its unenabled. If I enable it, it automatically works.

Based off your description, I think you swapped bomb and root variables, and root is bomb, bomb is character.

1 Like

I checked, its not that sadly. I used print statements to run through the instances and every child and everything seems right but for some reason it isn’t.

1 Like

Also your code:
weld.Part0 = bomb.Bomb
After reading that, I can make conclusion that bomb = Players.Violet_sheer
First mistake possible is that bomb is PLAYER. Even if I’ll skip this mistake, Player hasn’t any models. Player.Character has them. So use bomb.Character.Bomb instead.

2 Likes

Yeah I realized that I was actually saying bomb = bomber which bomber is a player. I can’t seem to get the model to position properly though because when I use MoveTo or PivotTo, instead of going where I wanted to, it’ll move a colossal amount of studs away.

Try to look where character’s pivot is. I had such problems, where pivot was set to world’s origin, and player spawned far away.


Also when I die it automatically moves to my position.

Looks like mistake in your bomb positioning.

I think its the order of my script because I said something along the lines of bomb:MoveTo(root.Position + Vector3.new(0,0,2)) and tried lookvectors.

When I teleport it doesn’t work, when I don’t, it does. If I don’t wrap the loop in a task.spawn function then it’ll run forever which makes the events in the future never happen.

How can I prevent teleporting from messing up my positioning?

I found the issue! I just positioned players after creating the gamemodes.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.