What do you want to achieve? Keep it simple and clear!
Hello fellow developers of roblox, so for some reason script being called once and only once, by using prints for debounce i figured out what scripts thinks player is not inside of a region.
What is the issue? Include screenshots / videos if possible!
Described in 1st.
What solutions have you tried so far? Did you look for solutions on the Developer Hub? As i already stated, i used prints for debounce.
Code:
local Prompt = script.Parent
local Region = script.Parent.Parent.Parent.Parent.Region
local CloseThing = script.Parent.Parent.Parent.Parent.CloseThing
local TweenService = game:GetService("TweenService")
local Time = 5
CloseThing.Transparency = 1
CloseThing.CanCollide = false
function isInsideBrick(position, brick)
local v3 = brick.CFrame:PointToObjectSpace(position)
return (math.abs(v3.X) <= brick.Size.X / 2)
and (math.abs(v3.Y) <= brick.Size.Y / 2)
and (math.abs(v3.Z) <= brick.Size.Z / 2)
end
Prompt.Triggered:Connect(function(Plr)
local Torso = Plr.Character.PrimaryPart
print("Found Torso")
if (Torso and isInsideBrick(Torso.Position, Region)) then
print("Torso is inside brick")
Torso.Anchored = true
local MoveUp = TweenService:Create(Torso, TweenInfo.new(Time, Enum.EasingStyle.Quad), {Position = CloseThing.Position + Vector3.new(0,6,0)})
MoveUp:Play()
Torso.Anchored = false
CloseThing.Transparency = 0
CloseThing.CanCollide = true
task.wait(Time)
CloseThing.Transparency = 1
CloseThing.CanCollide = false
end
end)
Some additional info: REGION Is Anchored, and this is not a problem. REGION position is always same it’s do not change by script or somehow other. REGION Is right size and fully fits exact place where i use it.
When you said it ran once do you mean when you trigger the prompt it run once or whenever you trigger the prompt it only run one time and not the other time you trigger the prompt again?
Alright bumping this topic, I added tons prints as @enpiesie said and this didn’t give any result, all prints run only once. Code
local Prompt = script.Parent
local Region = script.Parent.Parent.Parent.Parent.Region
local CloseThing = script.Parent.Parent.Parent.Parent.CloseThing
local TweenService = game:GetService("TweenService")
local Time = 5
local Deb = false
CloseThing.Transparency = 1
CloseThing.CanCollide = false
function isInsideBrick(position, brick)
local v3 = brick.CFrame:PointToObjectSpace(position)
return (math.abs(v3.X) <= brick.Size.X / 2)
and (math.abs(v3.Y) <= brick.Size.Y / 2)
and (math.abs(v3.Z) <= brick.Size.Z / 2)
end
Prompt.Triggered:Connect(function(Plr)
if Deb then return end
Deb = true
local Torso = Plr.Character.PrimaryPart
print("Found torso, deb is true, torso inside brick")
if Torso and isInsideBrick(Torso.Position, Region) then
Torso.Anchored = true
local MoveUp = TweenService:Create(Torso, TweenInfo.new(Time, Enum.EasingStyle.Quad), {Position = CloseThing.Position + Vector3.new(0,7,0)})
print("Tween Created")
MoveUp:Play(); MoveUp.Completed:Wait()
print("Tween finished playing")
Torso.Anchored = false
CloseThing.Transparency = 0
CloseThing.CanCollide = true
task.wait(Time)
print("Task has been successfully executed.")
CloseThing.Transparency = 1
CloseThing.CanCollide = false
Deb = false
end
end)
local Prompt = script.Parent
local Region = script.Parent.Parent.Parent.Parent.Region
local CloseThing = script.Parent.Parent.Parent.Parent.CloseThing
local TweenService = game:GetService("TweenService")
local Time = 5
local Deb = false
Prompt.Triggered:Connect(function(Plr)
print("Prompt triggered and Deb = "..Deb)
if Deb then return end
Deb = true
local Torso = Plr.Character.PrimaryPart
print("Found torso, deb is true, torso inside brick")
if Torso and isInsideBrick(Torso.Position, Region) then
Torso.Anchored = true
local MoveUp = TweenService:Create(Torso, TweenInfo.new(Time, Enum.EasingStyle.Quad), {Position = CloseThing.Position + Vector3.new(0,7,0)})
print("Tween Created")
MoveUp:Play(); MoveUp.Completed:Wait()
print("Tween finished playing")
Torso.Anchored = false
CloseThing.Transparency = 0
CloseThing.CanCollide = true
task.wait(Time)
print("Task has been successfully executed.")
CloseThing.Transparency = 1
CloseThing.CanCollide = false
end
Deb = false
end)
function isInsideBrick(position, brick)
local v3 = brick.CFrame:PointToObjectSpace(position)
return (math.abs(v3.X) <= brick.Size.X / 2)
and (math.abs(v3.Y) <= brick.Size.Y / 2)
and (math.abs(v3.Z) <= brick.Size.Z / 2)
end