How to add mobille suport to my game?

You can write your topic however you want, but you need to answer these questions:

  1. **What do you want to achieve? working mobille e button to pick up props like in half blox 2

  2. What is the issue? i cant add mobile button [e button to work on mobile from free model

-- This is an example Lua code block
PhysicsService = game:GetService("PhysicsService")
InputService = game:GetService("UserInputService") -- Used for detecting keyboard presses, etc.
TweenService = game:GetService("TweenService") -- Used for detecting keyboard presses, etc.
RunService = game:GetService("RunService")

LocalPlayer = game.Players.LocalPlayer -- Get the local player
Camera = game.Workspace.CurrentCamera -- Get the player's camera
Mouse = LocalPlayer:GetMouse() -- Get the player's mouse
Props = workspace:WaitForChild("Props") -- Get the props folder in workspace
PickupPropEvent = game.ReplicatedStorage:WaitForChild("PickupProp") -- Get the PickupProp event in ReplicatedStorage
Config = workspace:WaitForChild("Config") -- Get the Config folder in the PropPickup model

Holding = nil
O_Friction = 0
O_Density = 0
HoldDistance = 0

LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson -- Make the player go into first person mode.
InputService.MouseIconEnabled = false -- Make the mouse invisible.
InputService.MouseBehavior = Enum.MouseBehavior.LockCenter -- Make the mouse locked to the center of the screen.


function KeyPressed(Input, GameProcessedEvent)
	if GameProcessedEvent then -- This will make sure not to detect keys if the player is typing in a text box, such as the chat.
		return
	end
	
	local Key = Input.KeyCode -- This gets the keycode of the input
	
	if Key == Enum.KeyCode.E then -- This checks that the player presses E
		local Target = Mouse.Target
		local Character = LocalPlayer.Character
		if not Character then
			return
		end
		
		local Root = Character:FindFirstChild("HumanoidRootPart")
		if not Root then
			return
		end
		
		
		if Holding then -- If the player is holding a prop (this is for letting go of the prop with E)
			Drop()
		elseif Target and Target.Parent == Props then -- Check that the character exists, and then check if the player is looking at at a prop,
			local Prop = Target
			local Distance = (Root.Position - Prop.Position).Magnitude -- Get the distance from the player to the prop
			if Distance < tonumber(Config.PickupDistance.Value) then
				Pickup(Prop)
			end
		end
	end
end

InputService.InputBegan:connect(KeyPressed)

function Pickup(Prop)
	if Holding then
		return
	end
	if Prop:IsA("Model") then
		return
	end
	
	Holding = Prop
	
	Prop.Anchored = false
	
	PhysicsService:SetPartCollisionGroup(Prop, "Prop_Holding") -- Sets the collision group of the prop, so it doesn't collide with the player.
	
	PickupPropEvent:FireServer(Prop) -- Fire the event so the server knows we have picked up the prop.
	
	local CPP = Holding.CustomPhysicalProperties
	
	if not CPP then -- If the CustomPhysicalProperties on the part are disabled
		Prop.CustomPhysicalProperties = PhysicalProperties.new(7.85, 0.25, 1) -- Sets the CustomPhysicalProperties to something
		CPP = Holding.CustomPhysicalProperties -- Changes the variable to the new CustomPhysicalProperties
	end
	
	local DefaultHoldDistance = tonumber(Config.HoldDistance.Value)
	local ForceHoldDistance = Prop:FindFirstChild("HoldDistance")
	if ForceHoldDistance then
		HoldDistance = tonumber(ForceHoldDistance.Value)
	else
		HoldDistance = DefaultHoldDistance
	end
	
	local N_Density = 0.1
	O_Friction = CPP.Friction
	O_Density = CPP.Density
	Prop.CustomPhysicalProperties = PhysicalProperties.new(N_Density, 0.01, 0, 5, 100)
	-- The line above reduces the density and friction, so it's easier to hold and doesn't get stuck to walls.

	local BodyGyro = Instance.new("BodyGyro")
	BodyGyro.MaxTorque = Vector3.new(40000, 40000, 40000)
	BodyGyro.D = 50
	BodyGyro.P = 700
	BodyGyro.Parent = Prop
	
	local BodyPosition = Instance.new("BodyPosition")
	BodyPosition.D = 60
	BodyPosition.P = 0
	BodyPosition.Parent = Prop
	
	local Info = TweenInfo.new(0.7)
	local Tween = TweenService:Create(BodyPosition, Info, {P = 1200}) -- This smoothly brings up the power of the BodyPosition so the prop doesn't get flung.
	Tween:Play()
end

function LetGo()
	local BodyGyro = Holding:FindFirstChild("BodyGyro")
	local BodyPosition = Holding:FindFirstChild("BodyPosition")
	
	PhysicsService:SetPartCollisionGroup(Holding, "Default")
	
	Holding.CustomPhysicalProperties = PhysicalProperties.new(O_Density, O_Friction, Holding.CustomPhysicalProperties.Elasticity) 
	-- The line above sets the Density and Friction back to normal
	
	BodyPosition:Destroy()
	BodyGyro:Destroy()
end

function Drop()
	if not Holding then
		return
	end
	
	LetGo()
	Holding.Velocity = Holding.Velocity / 3 -- Reduce the velocity when dropping so the prop can be flung very far
	Holding = nil
end



function RenderStepped()
	if Holding then
		local BodyPosition = Holding:FindFirstChild("BodyPosition")
		local BodyGyro = Holding:FindFirstChild("BodyGyro")

		if BodyPosition and BodyGyro then
			-- Calculate the hold position without orientation
			local HoldPosition = Camera.CFrame.Position + Camera.CFrame.LookVector * HoldDistance

			BodyPosition.Position = HoldPosition -- Set the BodyPosition's position to the HoldPosition

			-- Update the prop's rotation to match the camera's rotation
			local cameraLook = Camera.CFrame.LookVector
			local angle = math.atan2(-cameraLook.Z, cameraLook.X) + math.rad(90) -- Calculate the angle between camera's look vector and X-axis

			BodyGyro.CFrame = CFrame.new(HoldPosition) * CFrame.Angles(0, angle, 0) -- Set the BodyGyro's CFrame to rotate the prop accordingly
		end
	end
end

RunService.RenderStepped:Connect(RenderStepped)

From this free model https://create.roblox.com/store/asset/4928759151/Prop-Pickup%3Fkeyword=&pageNumber=&pagePosition=

Hi! Try this:

function KeyPressed(Input:InputObject, GameProcessedEvent)
	if GameProcessedEvent then -- This will make sure not to detect keys if the player is typing in a text box, such as the chat.
		return
	end

	local Key = Input.KeyCode -- This gets the keycode of the input
	
	if InputService.TouchEnabled then
		if Input.UserInputType == Enum.UserInputType.MouseButton1 then
			local Target = Mouse.Target
			local Character = LocalPlayer.Character
			if not Character then
				return
			end

			local Root = Character:FindFirstChild("HumanoidRootPart")
			if not Root then
				return
			end


			if Holding then -- If the player is holding a prop (this is for letting go of the prop with E)
				Drop()
			elseif Target and Target.Parent == Props then -- Check that the character exists, and then check if the player is looking at at a prop,
				local Prop = Target
				local Distance = (Root.Position - Prop.Position).Magnitude -- Get the distance from the player to the prop
				if Distance < tonumber(Config.PickupDistance.Value) then
					Pickup(Prop)
				end
			end
		end
	end
	
	if Key == Enum.KeyCode.E then -- This checks that the player presses E
		local Target = Mouse.Target
		local Character = LocalPlayer.Character
		if not Character then
			return
		end

		local Root = Character:FindFirstChild("HumanoidRootPart")
		if not Root then
			return
		end


		if Holding then -- If the player is holding a prop (this is for letting go of the prop with E)
			Drop()
		elseif Target and Target.Parent == Props then -- Check that the character exists, and then check if the player is looking at at a prop,
			local Prop = Target
			local Distance = (Root.Position - Prop.Position).Magnitude -- Get the distance from the player to the prop
			if Distance < tonumber(Config.PickupDistance.Value) then
				Pickup(Prop)
			end
		end
	end
end

you need to change function KeyPressed to this

So this is for mobile button? I will try

no, I just added this

if InputService.TouchEnabled then
		if Input.UserInputType == Enum.UserInputType.MouseButton1 then
			local Target = Mouse.Target
			local Character = LocalPlayer.Character
			if not Character then
				return
			end

			local Root = Character:FindFirstChild("HumanoidRootPart")
			if not Root then
				return
			end


			if Holding then -- If the player is holding a prop (this is for letting go of the prop with E)
				Drop()
			elseif Target and Target.Parent == Props then -- Check that the character exists, and then check if the player is looking at at a prop,
				local Prop = Target
				local Distance = (Root.Position - Prop.Position).Magnitude -- Get the distance from the player to the prop
				if Distance < tonumber(Config.PickupDistance.Value) then
					Pickup(Prop)
				end
			end
		end
	end

Ok i seeee i will try add this

just paste new version of function KeyPressed (that I’ve already sent)

Allright i will pase it and see if its working

nope its not working sad face :frowning:

PhysicsService = game:GetService(“PhysicsService”)
InputService = game:GetService(“UserInputService”) – Used for detecting keyboard presses, etc.
TweenService = game:GetService(“TweenService”) – Used for detecting keyboard presses, etc.
RunService = game:GetService(“RunService”)

LocalPlayer = game.Players.LocalPlayer – Get the local player
Camera = game.Workspace.CurrentCamera – Get the player’s camera
Mouse = LocalPlayer:GetMouse() – Get the player’s mouse
Props = workspace:WaitForChild(“Props”) – Get the props folder in workspace
PickupPropEvent = game.ReplicatedStorage:WaitForChild(“PickupProp”) – Get the PickupProp event in ReplicatedStorage
Config = workspace:WaitForChild(“Config”) – Get the Config folder in the PropPickup model

Holding = nil
O_Friction = 0
O_Density = 0
HoldDistance = 0

LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson – Make the player go into first person mode.
InputService.MouseIconEnabled = false – Make the mouse invisible.
InputService.MouseBehavior = Enum.MouseBehavior.LockCenter – Make the mouse locked to the center of the screen.

function KeyPressed(Input, GameProcessedEvent)
if GameProcessedEvent then – This will make sure not to detect keys if the player is typing in a text box, such as the chat.
return
end

local Key = Input.KeyCode -- This gets the keycode of the input

if Key == Enum.KeyCode.E then -- This checks that the player presses E
	local Target = Mouse.Target
	local Character = LocalPlayer.Character
	if not Character then
		return
	end
	
	local Root = Character:FindFirstChild("HumanoidRootPart")
	if not Root then
		return
	end
	
	
	if Holding then -- If the player is holding a prop (this is for letting go of the prop with E)
		Drop()
	elseif Target and Target.Parent == Props then -- Check that the character exists, and then check if the player is looking at at a prop,
		local Prop = Target
		local Distance = (Root.Position - Prop.Position).Magnitude -- Get the distance from the player to the prop
		if Distance < tonumber(Config.PickupDistance.Value) then
			Pickup(Prop)
		end
	end
end

end

InputService.InputBegan:connect(KeyPressed)

function Pickup(Prop)
if Holding then
return
end
if Prop:IsA(“Model”) then
return
end

Holding = Prop

Prop.Anchored = false

PhysicsService:SetPartCollisionGroup(Prop, "Prop_Holding") -- Sets the collision group of the prop, so it doesn't collide with the player.

PickupPropEvent:FireServer(Prop) -- Fire the event so the server knows we have picked up the prop.

local CPP = Holding.CustomPhysicalProperties

if not CPP then -- If the CustomPhysicalProperties on the part are disabled
	Prop.CustomPhysicalProperties = PhysicalProperties.new(7.85, 0.25, 1) -- Sets the CustomPhysicalProperties to something
	CPP = Holding.CustomPhysicalProperties -- Changes the variable to the new CustomPhysicalProperties
end

local DefaultHoldDistance = tonumber(Config.HoldDistance.Value)
local ForceHoldDistance = Prop:FindFirstChild("HoldDistance")
if ForceHoldDistance then
	HoldDistance = tonumber(ForceHoldDistance.Value)
else
	HoldDistance = DefaultHoldDistance
end

local N_Density = 0.1
O_Friction = CPP.Friction
O_Density = CPP.Density
Prop.CustomPhysicalProperties = PhysicalProperties.new(N_Density, 0.01, 0, 5, 100)
-- The line above reduces the density and friction, so it's easier to hold and doesn't get stuck to walls.

local BodyGyro = Instance.new("BodyGyro")
BodyGyro.MaxTorque = Vector3.new(40000, 40000, 40000)
BodyGyro.D = 50
BodyGyro.P = 700
BodyGyro.Parent = Prop

local BodyPosition = Instance.new("BodyPosition")
BodyPosition.D = 60
BodyPosition.P = 0
BodyPosition.Parent = Prop

local Info = TweenInfo.new(0.7)
local Tween = TweenService:Create(BodyPosition, Info, {P = 1200}) -- This smoothly brings up the power of the BodyPosition so the prop doesn't get flung.
Tween:Play()

end

function LetGo()
local BodyGyro = Holding:FindFirstChild(“BodyGyro”)
local BodyPosition = Holding:FindFirstChild(“BodyPosition”)

PhysicsService:SetPartCollisionGroup(Holding, "Default")

Holding.CustomPhysicalProperties = PhysicalProperties.new(O_Density, O_Friction, Holding.CustomPhysicalProperties.Elasticity) 
-- The line above sets the Density and Friction back to normal

BodyPosition:Destroy()
BodyGyro:Destroy()

end

function Drop()
if not Holding then
return
end

LetGo()
Holding.Velocity = Holding.Velocity / 3 -- Reduce the velocity when dropping so the prop can be flung very far
Holding = nil

end

function RenderStepped()
if Holding then
local BodyPosition = Holding:FindFirstChild(“BodyPosition”)
local BodyGyro = Holding:FindFirstChild(“BodyGyro”)

	if BodyPosition and BodyGyro then
		-- Calculate the hold position without orientation
		local HoldPosition = Camera.CFrame.Position + Camera.CFrame.LookVector * HoldDistance

		BodyPosition.Position = HoldPosition -- Set the BodyPosition's position to the HoldPosition

		-- Update the prop's rotation to match the camera's rotation
		local cameraLook = Camera.CFrame.LookVector
		local angle = math.atan2(-cameraLook.Z, cameraLook.X) + math.rad(90) -- Calculate the angle between camera's look vector and X-axis

		BodyGyro.CFrame = CFrame.new(HoldPosition) * CFrame.Angles(0, angle, 0) -- Set the BodyGyro's CFrame to rotate the prop accordingly
	end
end

end

RunService.RenderStepped:Connect(RenderStepped)

i found another free model but it dont have mobile support