Why does this sword teleport me back when i equip it?

Hello! :smiley:

  1. What do you want to achieve? Keep it simple and clear!
    I created and scripted a gamepass that gives anyone who buys it a sword.

  2. What is the issue? Include screenshots / videos if possible!
    The gamepass works fine but the issue is that whenever someone tries to equip the sword it teleports them back I need help with fixing this issue.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried looking on the Developer Hub but still couldn’t fix the issue.

I will put all the gamepass scripts incase you might think there’s something wrong with any of them also it’d be nice if you can tell me if there’s any improvements that I can make to the scripts.

PromptPurchase Handler
local MarketPlaceService = game:GetService("MarketplaceService")

local gamePassID = 8609174

local function promptPurchase()
	local player = game.Players.LocalPlayer
	
	local havethePass = false
	
	local success, errormessage = pcall(function()
		havethePass = MarketPlaceService:UserOwnsGamePassAsync(player, gamePassID)
	end)
	
	if havethePass == true then
		print("Player has the give sword gamepass")
		MarketPlaceService:PromptGamePassPurchase(player, gamePassID)
	else
		MarketPlaceService:PromptGamePassPurchase(player, gamePassID)
	end
end
The gamepass handler
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sword = ReplicatedStorage:WaitForChild("ClassicSword")

local gamePassID = 8609174

MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassID, purchaseSuccess)
	if purchaseSuccess == true and purchasePassID == gamePassID then
		print(player.Name.." has the give sword gamepass")
		Sword.Parent = player.Character
	end
end)
Giving the players the sword when they join again
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sword = ReplicatedStorage:WaitForChild("ClassicSword")

local gamePassID = 8609174

game.Players.PlayerAdded:Connect(function(player)
	wait(5)
	
	local char = game.Workspace:FindFirstChild(player.Name)
	
	local hasPass = false
	
	local success, errormessage = pcall(function()
		havethePass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)
	
	if havethePass == true then
		print(player.Name.." has the give sword gamepass purchased")
		Sword.Parent = char
	end
end)
1 Like

Is the sword anchored? Did you try moving the sword close to them first? Is the sword connected to or by any sort of constraint on the map? Also, why are you giving everyone the same exact sword? Clone it with :Clone() and make sure to give it to them when they respawn too.

The sword model is prob anchored.

  1. No the sword isn’t anchored.

  2. The sword’s handler only has a Weld in it.

  3. This isn’t an actual game that I am releasing to the public I just wanted to practice on how to script gamepasses.

I would suggest using :Clone() as @Wunder_Wulfe said earlier, as that is considered good practice.

Do you have any screenshots? If so, please send…

Alright but I don’t think that’s the issue because I tested these scripts in solo play mode

Here’s a video of what’s happening:

What is the weld for? Mesh and handle?

Sword obviously looks anchored or welded to something like the baseplate…

It looks anchored but he said it isnt…

Well the only reason it would act like it is if it is anchored or attached to something that is anchored.
There is literally no other reason that this would happen for. OP probably didn’t make 100% sure that the sword is not anchored or welded / attached to the ground, at least not in play mode. Maybe it could have automatically attached to the Baseplate by the automatic joining of surfaces when placing a brick onto one.

make sure your handle isn’t anchored

Unanchor the handle. Also, I suggest you disable CanCollide for better experience. Use qPerfectionWeld if you have multiple parts of a sword.

1 Like

Just to confirm that the sword’s Handler isn’t Anchored here’s a video showing it:

what is it welded to (30 charcater

It’s not anchored and the video above confirms that.

That weld might have something to do with it.

1 Like

That does not show if it is anchored or not at all. Show the tool in-game when the character is holding it and it is in their hands (it will be in their Character). It will be obvious if something is wrong

What is in the constraints for the weld?

1 Like