Script breaking when moved to another game, it works fine in the original game

i have a transmutation (teleportation) script that works perfectly in one game, but when i put it in my other game, it refuses to teleport me or do anything. the remote event fires and is picked up on the server, i did print checks for it and it worked, however the player doesn’t teleport at all.

local script in starter character scripts:

wait(2)

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("Transmutation") or ReplicatedStorage:FindFirstChild("Transmutation")
local Mouse = Player:GetMouse()
local UserInputService = game:GetService("UserInputService")

repeat
	wait()
until Character.Parent == workspace

local Debounce = false

UserInputService.InputBegan:Connect(function(Input, gameProcessed)
	if not gameProcessed and not Character:FindFirstChild("disableTransmutation") then
		if Input.KeyCode == Enum.KeyCode.Q and not Debounce and Mouse.Target and Character.Humanoid.Health > 0 and not Character.Humanoid.PlatformStand  then
			Debounce = true
			Event:FireServer()
			wait(2)
			Debounce = false
		end
	end
end)

normal script in server script service:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Event = ReplicatedStorage:WaitForChild("Transmutation")
local Debris = game:GetService("Debris")
local Mouse = ReplicatedStorage:WaitForChild("Mouse")
local tweenClient = ReplicatedStorage:WaitForChild("tweenClient")
local Message = ReplicatedStorage:WaitForChild("Message")

local function getMaxDistance(Player)
	local Rank = Player:WaitForChild("GroupRank").Value
	if Rank == 1 then -- Neophyte
		return 5
	elseif Rank == 2 then -- Intermediate
		return 8
	elseif Rank == 3 then -- Adept
		return 10
	elseif Rank == 4 then -- Proficient
		return 15
	elseif Rank == 5 then -- Apprentice
		return 20
	elseif Rank == 6 then -- Intelligent
		return 25
	elseif Rank == 7 then -- Veteran
		return 32
	elseif Rank == 8 then -- Mastery
		return 40
	elseif Rank == 9 then -- Prefect
		return 45
	elseif Rank == 15 then -- Corps de Garde
		return 75
	elseif Rank == 20 then -- Intern
		return 55
	elseif Rank == 22 then -- Professor
		return 55
	elseif Rank == 24 then -- Senior Lecturer
		return 60
	elseif Rank == 26 then -- Academician
		return 65
	elseif Rank == 28 then -- Head Consutlant
		return 70
	elseif Rank == 30 then -- Witch Council
		return 70
	elseif Rank == 32 then -- Head Councillor
		return 70
	elseif Rank == 40 then -- Supremacy
		return 250
	elseif Rank == 44 then -- Witchcraft Directorates
		return 75
	elseif Rank == 50 then -- Superintendence
		return 80
	elseif Rank == 54 then -- Headministry
		return 90
	elseif Rank == 252 then -- Ethereal Architect
		return 10000
	elseif Rank == 253 then -- Ethereal Government
		return 1000
	elseif Rank == 254 then -- Ethereal Doorkeeper
		return 1000
	elseif Rank == 255 then -- Ethereal Overseer
		return 1000
	end
end

local function Teleport(Player, Position)
	local soundEffect = script.Effect:Clone()
	soundEffect.Parent = Player.Character.HumanoidRootPart
	soundEffect.Stopped:Connect(function()
		soundEffect:Destroy()
	end)
	soundEffect:Play()
	wait(0.3)
	for _,v in next, Player.Character:GetDescendants() do
		if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" and v.Name ~= "Collide_Part" and not v.Parent:IsA("Tool") then
			local Clone = v:Clone()
			Clone.CanCollide = false
			Clone.Name = "Transmutation"
			Clone.BrickColor = BrickColor.new("Really black")
			local Face = Clone:FindFirstChildOfClass("Decal")
			if Face then
				Face:Destroy()
			end
			local Face2 = v:FindFirstChildOfClass("Decal")
			if Face2 then
				Face2.Transparency = 1
			end
			Clone.Parent = workspace
			tweenClient:FireAllClients({Clone, 0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, {Transparency = 1, Size = v.Size + Vector3.new(1, 1, 1)}})
			tweenClient:FireAllClients({v, 0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, {Transparency = 1}})
			Debris:AddItem(Clone, 0.3)
		end
	end
	wait(0.3)
	Player.Character:MoveTo(Position)
	wait(0.8)
	for _,v in next, Player.Character:GetDescendants() do
		if v:IsA("BasePart")and v.Name ~= "HumanoidRootPart" and v.Name ~= "Collide_Part" and not v.Parent:IsA("Tool") then
			local Clone = v:Clone()
			Clone.CanCollide = false
			Clone.Name = "Transmutation"
			Clone.BrickColor = BrickColor.new("Really black")
			local Face = Clone:FindFirstChildOfClass("Decal")
			if Face then
				Face:Destroy()
			end
			local Face2 = v:FindFirstChildOfClass("Decal")
			if Face2 then
				Face2.Transparency = 0
			end
			Clone.Parent = workspace
			tweenClient:FireAllClients({Clone, 0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, {Transparency = 1, Size = v.Size + Vector3.new(1, 1, 1)}})
			tweenClient:FireAllClients({v, 0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, {Transparency = 0}})
			Debris:AddItem(Clone, 0.3)
		end
	end
end

Event.OnServerEvent:Connect(function(Player)
	local success, errorMessage = pcall(function()
		if Player and Player.Character and Player.Character:FindFirstChild("Head") then
			local Position = Mouse:InvokeClient(Player, "Position")
			local Distance, maxDistance = (Position - Player.Character.Head.Position).Magnitude, getMaxDistance(Player)
			if Distance > maxDistance then
				ReplicatedStorage.Message:FireClient(Player, "You are not powerful enough to transmutate that far.")
				return
			end
			local MultiAppa = false
			if Player:WaitForChild("GroupRank").Value >= 12 then
				MultiAppa = true
			end
			if MultiAppa and not Player.Character:FindFirstChild("disableMulti") then
				for i,v in next, Players:GetPlayers() do
					if v.Character and v ~= Player then
						if v.Character:FindFirstChild("Head") then
							if (v.Character.Head.Position - Player.Character.Head.Position).Magnitude <= 5 then
								spawn(function()
									local newPos = Position + Vector3.new(math.random(-5, 5), 0, math.random(-5, 5))
									Teleport(v, newPos)
								end)
							end
						end
					end
				end
			end
			Teleport(Player, Position)
		end
	end)
	if errorMessage then
		warn(errorMessage)
	end
end)

i have no idea why it’s not working.

everything is there exactly like it is in the other game, and nothing is missing but it’s not working. there are values for group rank and everything and it still doesn’t work.

nothing in output

1 Like

I got the scripts to work but I had to write a number of other scripts to handler events, so these scripts alone will not work.
Here was my simple working copy:
teleport.rbxl (36.6 KB)

I don’t know how you implemented the other events and functions that are not included in those scripts, maybe there is a different there? Without more information about the differences between the two places, unfortunately I can’t solve this because there has to be some difference somewhere.
You could also try using the debugger, it may help seeing what failed

Also, unrelated but just my 2 cents: the getMaxDistance function could be replaced by a table lookup, for example:

local MaxDistances = {
  [1] = 5,
  [2] = 8,
  [3] = 10
  -- continue for all ranks
}
function getMaxDistance(Player)
  local Rank = Player:WaitForChild("GroupRank").Value
  return MaxDistances[Rank]
end

And I’m not positive, but GroupRank may be insecure – players may be able to modify it – so it may be better to store it in ServerStorage or in a ModuleScript

thank you! i will try the script and then i may modify the function into a table, but i will make changes later. thank you so much!

I have tried your script and unfortunately I do not teleport, the effect works though.

I just don’t teleport at all
https://gyazo.com/1ba53cb3227a9b59242e06d08398135e

Maybe make sure again that the script actually works as intended in your other game. Maybe try setting your avatar to r15 or r6 and see if anything has changed?

Might be worth variable tracking here.

if Input.KeyCode == Enum.KeyCode.Q and not Debounce and Mouse.Target and Character.Humanoid.Health > 0 and not Character.Humanoid.PlatformStand  then

All looks good, but if you can check whether this if statement’s being evaluated properly then it might affect whether the remote event is actually fired.

Might also be worth throwing a print in the server-side script to confirm that the RE is being fired.

i’ve done 2 prints, one in the local to say it was fired and one in the server side script to say it was picked up - both worked

it does, i’ve played that other game today. the script only works for r15 as far as i’m aware but my character is always r15 so it wont be an issue with the body type.

1 Like

i’ve tried removing all of the checks except for the keycode check and it still doesn’t work

there’s an issue with the layered clothing which prevents the transmutation for some reason, i’ll have to find out how to fix that or disable layered clothing from my game

Were there any errors when it failed? If there are no errors, maybe you could try removing all code but the parts that do the actual transmutation (remove the animations, etc.) and try again

there are no errors, however i have just disabled layered clothing from my game as of now and when i can fix it i will re enable layered clothing