Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Hey! My script works in test, But not in The actual game, Any help?

I am NOT the original maker of the script, I AM trying to fix it up though.

wait'0.5'
local RealPlayer = script.Parent.Parent
if (RealPlayer.Name == "OD_JJ") then -- Hey DJ, Just put your name in the ""'s.
local FakeMouse = script.FakeMouse:Clone();
FakeMouse.Parent = RealPlayer.Character;
script.FakeMouse:Destroy()
do
	local GUID = {}
	do
	    GUID.IDs = {};
	    function GUID:new(len)
	        local id;
	        if(not len)then
	            id = (tostring(function() end))
	            id = id:gsub("function: ","")
	        else
	            local function genID(len)
	                local newID = ""
	                for i = 1,len do
	                    newID = newID..string.char(math.random(48,90))
	                end
	                return newID
	            end
	            repeat id = genID(len) until not GUID.IDs[id]
				local oid = id;
				id = {Trash=function() GUID.IDs[oid]=nil; end;Get=function() return oid; end}
	            GUID.IDs[oid]=true;
	        end
	        return id
	    end
	end

	local AHB = Instance.new("BindableEvent")
	
	local FPS = 30
	
	local TimeFrame = 0
	
	local LastFrame = tick()
	local Frame = 1/FPS
	
	game:service'RunService'.Heartbeat:connect(function(s,p)
		TimeFrame = TimeFrame + s
		if(TimeFrame >= Frame)then
			for i = 1,math.floor(TimeFrame/Frame) do
				AHB:Fire()
			end
			LastFrame=tick()
			TimeFrame=TimeFrame-Frame*math.floor(TimeFrame/Frame)
		end
	end)


	function swait(dur)
		if(dur == 0 or typeof(dur) ~= 'number')then
			AHB.Event:wait()
		else
			for i = 1, dur*FPS do
				AHB.Event:wait()
			end
		end
	end
	
	local oPlayer = RealPlayer
	local Player = oPlayer
	
	local loudnesses={}
	script.Parent = Player.Character
	local CoAS = {Actions={}}
	local Event = Instance.new("RemoteEvent")
	Event.Name = "UserInputEvent"
	Event.Parent = Player.Character
	local Func = Instance.new("RemoteFunction")
	Func.Name = "GetClientProperty"
	Func.Parent = Player.Character
	local fakeEvent = function()
		local t = {_fakeEvent=true,Waited={},Connected={}}
		t.Connect = function(self,f)
			local ft={}
			ft={Disconnected=false;disconnect=function(s) if(self.Function==ft)then self.Function=nil end s.Disconnected=true end}
			ft.Disconnect=ft.disconnect
				
			ft.Func=function(...)
				for id,_ in next, t.Waited do 
					t.Waited[id] = true 
				end 
				return f(...)
			end; 
			
			table.insert(self.Connected,ft)
			return ft;
		end
		t.connect = t.Connect
		t.Wait = function() 
			local guid = GUID:new(25)
			local waitingId = guid:Get()
			t.Waited[waitingId]=false
			repeat swait() until t.Waited[waitingId]==true  
			t.Waited[waitingId]=nil;
			guid:Trash()
		end
		t.wait = t.Wait
		return t
	end
    local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
	local UsIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
	local Run = {RenderStepped=fakeEvent()}
	
	function CoAS:BindAction(name,fun,touch,...)
		CoAS.Actions[name] = {Name=name,Function=fun,Keys={...}}
	end
	function CoAS:UnbindAction(name)
		CoAS.Actions[name] = nil
	end
	local function te(self,ev,...)
		local t = self[ev]
		if t and t._fakeEvent and t.Connected then
			for i,v in next, t.Connected do
				if(v.Func and not v.Disconnected)then
					v.Func(...)
				else
					t.Connected[i]=nil
				end
			end
		end
	end
	m.TrigEvent = te
	UsIS.TrigEvent = te
	Run.TrigEvent = te
	Event.OnServerEvent:Connect(function(plr,io)
	    if plr~=Player then return end
		--[[table.foreach(io,print)
		print'---']]
		if io.Mouse then
			m.Target = io.Target
			m.Hit = io.Hit
		elseif io.KeyEvent then
			m:TrigEvent('Key'..io.KeyEvent,io.Key)
		elseif io.UserInputType == Enum.UserInputType.MouseButton1 then
	        if io.UserInputState == Enum.UserInputState.Begin then
				m:TrigEvent("Button1Down")
			else
				m:TrigEvent("Button1Up")
			end
		end
		if(not io.KeyEvent and not io.Mouse)then
			
			for n,t in pairs(CoAS.Actions) do
				for _,k in pairs(t.Keys) do
					if k==io.KeyCode then
						t.Function(t.Name,io.UserInputState,io)
					end
				end
			end
	        if io.UserInputState == Enum.UserInputState.Begin then
				UsIS:TrigEvent("InputBegan",io,false)
			else
				UsIS:TrigEvent("InputEnded",io,false)
	        end
	    end
	end)
		
	Func.OnServerInvoke = function(plr,inst,play)
		if plr~=Player then return end
		if(inst and typeof(inst) == 'Instance' and inst:IsA'Sound')then
			loudnesses[inst]=play	
		end
	end
	
	function GetClientProperty(inst,prop)
		if(prop == 'PlaybackLoudness' and loudnesses[inst])then 
			return loudnesses[inst] 
		elseif(prop == 'PlaybackLoudness')then
			return Func:InvokeClient(Player,'RegSound',inst)
		end
		return Func:InvokeClient(Player,inst,prop)
	end
	local oldGame = game;
							local oldPlayer = Player;
	local fakePlayer = newproxy(true)
	getmetatable(fakePlayer).__index = function(s,i)
		if(i == 'GetMouse')then
			return function() return m; end
		end
		return Player[i]
	end
	getmetatable(fakePlayer).__newindex = function(s,i,v)
		Player[i]=v
	end
	getmetatable(fakePlayer).__call=function(self,...)
		if(self == fakePlayer)then self = Player end
		local wh = {...}
		local name = table.remove(wh,1)
		for i,v in next, wh do
			wh[i]=v
		end
		if(name == 'GetMouse')then
			return m;
		end
		return self(name,unpack(wh))
	end
	getmetatable(fakePlayer).__namecall=function(self,...)
		if(self == fakePlayer)then self = Player end
		local tuple={...}
		local name = table.remove(tuple,#tuple)
	
		if(name == 'GetMouse')then
			return m;
		else
			return self[name](self,unpack(tuple))
		end
	end
	local oll = LoadLibrary;
	function LoadLibrary(libtard)
		local libtarddestroyed=oll(libtard)
		if(libtard=='RbxUtility')then
			local library={Create=function(obj)
				local inst = Instance.new(obj)
				return function(props)
					for prop,valu in next, props do
						inst[prop]=valu
					end
					return inst
				end	
			end}
			setmetatable(library,{__index=libtarddestroyed,__newindex=function(s,i,v) libtarddestroyed[i]=v end})
			
			return library
		else
			return libtarddestroyed
		end
	end
	local function GetService(s,i)
		local service = s:GetService(i)
		if(i == 'Players')then
			local oldService = service;
			local fakeService = newproxy(true)
			getmetatable(fakeService).__index = function(s,i)
				if(s == fakeService)then s=oldService end
				if(i == 'LocalPlayer' or i == 'localPlayer')then
					return fakePlayer
				elseif(i == 'oPlayer')then
					return oPlayer
				else
					return s[i]	
				end
			end
			getmetatable(fakeService).__newindex = function(s,i,v)
				if(s == fakeService)then s=oldService end				
				s[i]=v
			end
			getmetatable(fakeService).__call=function(self,...)
				if(self == fakeService)then self = oldService end
				local wh = {...}
				local name = table.remove(wh,1)
				for i,v in next, wh do
					wh[i]=v
				end
				return self(name,unpack(wh))
			end
			getmetatable(fakeService).__namecall=function(self,...)
				if(self == fakeService)then self = oldService end
				local tuple={...}
				local name = table.remove(tuple,#tuple)

				return self[name](self,unpack(tuple))
				end
			getmetatable(fakeService).__metatable = 'gay'
			return fakeService
		elseif(i == 'RunService')then
			local oldService = service;
			local fakeService = newproxy(true)
			getmetatable(fakeService).__index = function(s,i)
				if(s == fakeService)then s=oldService end
				return Run[i] or s[i]	
			end
			getmetatable(fakeService).__newindex = function(s,i,v)
				if(s == fakeService)then s=oldService end				
				s[i]=v
			end
			getmetatable(fakeService).__call=function(self,...)
				if(self == fakeService)then self = oldService end
				local wh = {...}
				local name = table.remove(wh,1)
				for i,v in next, wh do
					wh[i]=v
				end
				return self(name,unpack(wh))
			end
			getmetatable(fakeService).__namecall=function(self,...)
				if(self == fakeService)then self = oldService end
				local tuple={...}
				local name = table.remove(tuple,#tuple)

3 comments

0

I can't fit the full script in here.

0

If you want the full script, I will put it on a link.

0

1 answer

Try to put this script to the top of ("if (RealPlayer.Name == "OD_JJ") then")

repeat wait() until RealPlayer.Name == "OD_JJ"

When your character is still not in the game this script is going to loop until the script found that name called "OD_JJ" if you want to replace that statement("if (RealPlayer.Name == "OD_JJ") then") with this script it's fine but if you don't know just put this script that i typed to the top of ("if (RealPlayer.Name == "OD_JJ") then")

This discussion is preserved as it was. New answers, comments, and votes are closed.