Thx to T3_MasterGamer for the script if u see this can u help me again lol
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(input) if input.UserInputType == script.Parent.MouseButton1Click then local part2 = Instance.new("Part", workspace) part2.CanCollide = false part2.Anchored = true part2:PivotTo(character:WaitForChild("Head"):GetPivot() * CFrame.new(0, 0, 5)) part2.Name = "Part1" character:WaitForChild("Humanoid"):MoveTo(part2.Position, part2) end end)
What you're doing is wrong. You're trying to check if the input's UserInputType which is an event, not an enum. You don't need to use UserInputService.InputBegan
if you will change it to a mouse click. Replace that event with script.Parent.MouseButton1Click
event.
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() script.Parent.MouseButton1Click:Connect(function() local part2 = Instance.new("Part", workspace) part2.CanCollide = false part2.Anchored = true part2:PivotTo(character:WaitForChild("Head"):GetPivot() * CFrame.new(0, 0, 5)) part2.Name = "Part1" character:WaitForChild("Humanoid"):MoveTo(part2.Position, part2) end)
But if you want both for "E" and button (i assume for pc and mobile) you can create one function and connect that function to the two events (UserInputService.InputBegan
and GuiButton.MouseButton1Click
) altogether in one script (make sure that script is inside the button).
local player = game:GetService("Players").LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local UserInputService = game:GetService("UserInputService") function MovePlayer() local part2 = Instance.new("Part", workspace) part2.CanCollide = false part2.Anchored = true part2:PivotTo(character:WaitForChild("Head"):GetPivot() * CFrame.new(0, 0, 5)) part2.Name = "Part1" character:WaitForChild("Humanoid"):MoveTo(part2.Position, part2) end UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then MovePlayer() end end) script.Parent.MouseButton1Click:Connect(function() MovePlayer() end)