Hello! I would like to place the handle of my tool on a specific part using a placement system. Could someone please lend a hand?
server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local placeToolEvent = ReplicatedStorage:WaitForChild("placeObject")
placeToolEvent.OnServerEvent:Connect(function(player, tool)
if player.Team.Name == "Team 1" then
-- Placing the handle of my tool on a specific part.
else
warn(player.Name .. " does not have permission to place the tool.")
end
end)
localscript:
-- Assume that Cooking_Buttons_List is a GUI with buttons, and FrameToShowHide is the frame to show/hide
local button = script.Parent
local frameToShowHide = script.Parent.Parent.Parent.Parent.Loading_UI
local placeToolEvent = game:GetService("ReplicatedStorage"):WaitForChild("placeObject")
-- Duration in seconds to show the frame
local showDuration = 3
-- Reference to the tool in ReplicatedStorage
local specificTool = game.ReplicatedStorage.Tools:WaitForChild("Flash Light") -- Replace "YourSpecificTool" with the actual name of your tool
-- Function to show the frame and hide it after a specified time
local function showAndHideFrame()
print("Showing the frame...")
frameToShowHide.Visible = true -- Show the frame
wait(showDuration) -- Wait for the specified time
print("Hiding the frame...")
frameToShowHide.Visible = false -- Hide the frame after the specified time
-- Add the specific tool to the player's backpack
local player = game.Players.LocalPlayer
if player and specificTool then
print("Adding the specific tool to the player's backpack...")
local toolClone = specificTool:Clone()
toolClone.Parent = player.Backpack
else
warn("Player or specific tool not found.")
end
if specificTool then
--placeToolEvent:FireServer(specificTool)
else
warn("The specific tool is not found in the player's inventory.")
end
end
-- Connect the function to the MouseButton1Down event of the button
button.MouseButton1Down:Connect(function()
print("Button clicked, initiating showAndHideFrame function...")
showAndHideFrame()
end)
How can I continue my script to implement a placement system?