I’m trying to make a prompt that plays a tween which reduces the camera’s FOV and when its completed it returns to default, it works but im trying to make that when you relase the key and its not done yet it reverses to default to then start again when you hold it again.
ive putted prints and it prints “playing” and “waiting” but the tween dosent seem to play, also it works just fine the first time but if you do it again with the same prompt then it wont do anything…
I’ve tryed putting booleans but it did nothing, i dont know what to do…
server script:
local prompt = script.Parent
prompt.PromptButtonHoldBegan:Connect(function(plr)
game:GetService("ReplicatedStorage").CHANGEFOV:FireClient(plr)
script["Laser charge up"]:Play()
end)
prompt.Triggered:Connect(function(plr)
local collect = plr.PlayerGui:FindFirstChild("COLLECT").Background
local planks = math.random(2,4)
if script["Laser charge up"].Playing then
script["Laser charge up"]:Stop()
end
collect.TextLabel.Text = "You found " ..tostring(planks) .." Planks!"
collect.Visible = true
script.succes:Play()
if plr:FindFirstChild("STATS") then
print("STATS found!")
plr:FindFirstChild("STATS").WOODPLANKS.Value += planks
end
script.Parent.Parent.Transparency = 1
script.Parent.Parent.CanCollide = false
script.Parent.Enabled = false
task.wait(1)
script.Parent.Parent:Remove()
collect.TextButton.MouseButton1Click:Wait()
collect.Visible = false
end)
prompt.PromptButtonHoldEnded:Connect(function(plr)
if script["Laser charge up"].Playing then
script["Laser charge up"]:Stop()
end
game:GetService("ReplicatedStorage").STOPFOV:FireClient(plr)
end)
This is whats in the local script:
local tweenservice = game:GetService("TweenService")
local event = game:GetService("ReplicatedStorage").CHANGEFOV
local tweeninfo = TweenInfo.new(3,Enum.EasingStyle.Exponential)
local tweeninfo2 = TweenInfo.new(0.4,Enum.EasingStyle.Back)
local fovstarttween = tweenservice:Create(game.Workspace:WaitForChild("Camera"),tweeninfo,{FieldOfView = 50})
local fovreversetween = tweenservice:Create(game.Workspace:WaitForChild("Camera"),tweeninfo2,{FieldOfView = 70})
event.OnClientEvent:Connect(function()
print("playing")
fovstarttween:Play()
print("waiting")
fovstarttween.Completed:Wait()
print("reverse")
fovreversetween:Play()
end)
game:GetService("ReplicatedStorage").STOPFOV.OnClientEvent:Connect(function()
print("Tween stop request")
if fovstarttween.PlaybackState == Enum.PlaybackState.Playing then
print("Stopped")
fovstarttween:Cancel()
end
end)