Hello everyone! I am currently making a project where you press a button and clone papers, Using a button, And then you pick it up, And they have different rarities and qualities!
For some reason, When I pick it up, And press the button again, It then unequipped my item, And spawned it infront of me. It also never clones another object, Just unequipped mine. (The object is a tool, Its equippable and unequipabble)
Here is the code:
Object = game.ReplicatedStorage.Paper
Click = script.Parent.ClickDetector
Button = script.Parent
Sound = script.Printer
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
0.3, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
1, -- RepeatCount (when less than zero the tween will loop indefinitely)
true, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
function onClicked(playerWhoClicked) -- This function says when the part is clicked, it plays whatever sound
Click.MaxActivationDistance = nil
script.Parent.BrickColor = BrickColor.new("Really red")
Sound:Play()
script.Parent.Parent.Parent.screen.Part.SurfaceGui.SIGN.Text = "Printing"
local tween = TweenService:Create(Button, tweenInfo, {Position = Vector3.new(-14.166, 3.135, -22.403)})
tween:Play()
wait(0.6)
tween:Cancel() -- cancel the animation after 10 seconds
script.Parent.Parent.Parent.screen.Part.SurfaceGui.SIGN.Text = "Printing."
wait(0.5)
script.Parent.Parent.Parent.screen.Part.SurfaceGui.SIGN.Text = "Printing.."
wait(0.5)
script.Parent.Parent.Parent.screen.Part.SurfaceGui.SIGN.Text = "Printing..."
wait(0.5)
script.Parent.BrickColor = BrickColor.new("Lime green")
Click.MaxActivationDistance = 32
script.Parent.Parent.Parent.screen.Part.SurfaceGui.SIGN.Text = "Done!"
wait(0.5)
script.Parent.Parent.Parent.screen.Part.SurfaceGui.SIGN.Text = "Press the button."
Object:Clone()
Object.Parent = game.Workspace
Object.Position = Vector3.new(-15.175, 2.281, -18.514)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
This code fetches the object paper, from replicated storage and clones it in workspace. For some reason im able to pick it up, And when I press the button again it unequipped it and put it close infront of me. (This is a tool)