I’m trying to tween a player, and there are no errors, but the player won’t move. Here’s my script:
local prompt = script.Parent.ProximityPrompt
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local fireRepel = ReplicatedStorage.FireRepel
local endCFrame = game.Workspace.EndOfRope.Top.CFrame
local goal = {}
goal.Position = endCFrame
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
3,
Enum.EasingStyle.Quart,
Enum.EasingDirection.In,
0,
false
)
prompt.Triggered:Connect(function(plr)
fireRepel:FireClient(plr)
local hrp = plr.CharacterAdded:Wait():WaitForChild("HumanoidRootPart")
local repelTween = TweenService:Create(hrp, tweenInfo, goal)
repelTween:Play()
end)
How do I fix this?
Try this:
local prompt = script.Parent.ProximityPrompt
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local fireRepel = ReplicatedStorage.FireRepel
local endCFrame = game.Workspace.EndOfRope.Top.CFrame
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
3,
Enum.EasingStyle.Quart,
Enum.EasingDirection.In,
0,
false
)
prompt.Triggered:Connect(function(plr)
fireRepel:FireClient(plr)
local hrp = plr.CharacterAdded:Wait():WaitForChild("HumanoidRootPart")
local repelTween = TweenService:Create(hrp, tweenInfo, endCFrame)
repelTween:Play()
end)
I figured it out. I changed the script to this:
local prompt = script.Parent.ProximityPrompt
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local fireRepel = ReplicatedStorage.FireRepel
local endCFrame = game.Workspace.EndOfRope.Top.CFrame
local goal = {}
goal.CFrame = endCFrame
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
3,
Enum.EasingStyle.Quart,
Enum.EasingDirection.In,
0,
false
)
prompt.Triggered:Connect(function(plr)
fireRepel:FireClient(plr)
local character = plr.Character
if not character then
character = plr.CharacterAdded:Wait()
end
print("Character found")
local hrp = character:WaitForChild("HumanoidRootPart")
print("hrp found")
local repelTween = TweenService:Create(hrp, tweenInfo, goal)
repelTween:Play()
print("Tween played")
end)