Thanks for the help everyone, I appreciate it. However, I came up with my own solution.
server script:
character.PrimaryPart.Touched:Connect(function(hitPart)
if hitPart.Parent ~= folder then return end -- we want it to only touch apple
hitPart:SetAttribute("Activate", true)
task.wait(0.01)
print("yes")
hitPart.CFrame = CFrame.new(math.random(-100, 100), 2, math.random(-100, 100))
hitPart:SetAttribute("Activate", false)
--[[
createPart(character)
]]
character:WaitForChild("Humanoid").WalkSpeed += 5
end)
local script:
local CS = game:GetService("CollectionService")
local TS = game:GetService("TweenService")
local tweeningInfo = TweenInfo.new(
3,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
-1,
true,
0
)
local function onAppleAdded(v)
local tween = TS:Create(v, tweeningInfo, {CFrame = v.CFrame + v.CFrame.UpVector * 1.8})
tween:Play()
v:GetAttributeChangedSignal("Activate"):Connect(function()
tween:Cancel()
tween = TS:Create(v, tweeningInfo, {CFrame = v.CFrame + v.CFrame.UpVector * 1.8})
tween:Play()
end)
end
CS:GetInstanceAddedSignal("Apple"):Connect(onAppleAdded)
for i, v in CS:GetTagged("Apple") do
onAppleAdded(v)
end
The apples won’t be tweening at the same height, but I think it is inevitable.