You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
i want a little bit of help on the issue that is happening on my script , i dont know where is the part that is making the mess. -
What is the issue? Include screenshots / videos if possible!
Hello i made a edit mode system , when i try to edit one object , its all good , until i want to edit another object the old object duplicates with the new one and i dont know why
Watch 2024-08-07 20-16-24 | Streamable here is a video of my issue
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried looking some solutions but i cant find none of them worked so far i know
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Here is server side script and the client script :
---Client---
Client: local RS = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Plrs = game:GetService("Players")
local Plr = Plrs.LocalPlayer
local Mouse = Plr:GetMouse()
local RaycastParam = RaycastParams.new()
local Camera = workspace.CurrentCamera
local ShopSystem = workspace:WaitForChild("ShopSystem")
local BagProps = ShopSystem:WaitForChild("Bag/Props")
local EventsFolder = RS:WaitForChild("Events")
local Events = {EditMode = EventsFolder:WaitForChild("EditMode")}
local TemplateFolder = RS:WaitForChild("Templates"):WaitForChild("Buyable")
local UIS = game:GetService("UserInputService")
local CurrentCloner = nil
Events.EditMode.OnClientEvent:Connect(function(StringTagged,TaggedNameValue,SuppliesValue)
RaycastParam:AddToFilter(Plr.Character)
local DB = false
local FindNameOfTagged = TemplateFolder:FindFirstChild(TaggedNameValue)
local Supplies = SuppliesValue.Value
local Connection = SuppliesValue.Changed:Connect(function()
Supplies = SuppliesValue.Value
end)
local function AppearToolInMouse()
local ConnectionInputBegan
local ClonerTagged = FindNameOfTagged:Clone()
RaycastParam:AddToFilter(ClonerTagged)
ClonerTagged.Parent = workspace
ClonerTagged.Transparency = 0.5
local function cleanup()
if ConnectionInputBegan then
ConnectionInputBegan:Disconnect()
end
if ClonerTagged then
ClonerTagged:Destroy()
end
end
if CurrentCloner == nil then
CurrentCloner = ClonerTagged
elseif CurrentCloner ~= nil then
CurrentCloner:Destroy()
CurrentCloner = ClonerTagged
end
while Plr.Character:WaitForChild("InEditModeAlready").Value do
if Supplies >= 1 then
local raycast = workspace:Raycast(Mouse.UnitRay.Origin, Mouse.UnitRay.Direction * 1000, RaycastParam)
if raycast then
local Position = Vector3.new(ClonerTagged.Size.X / 2, ClonerTagged.Size.Y / 2, ClonerTagged.Size.Z / 2)
local RaycastNormal = raycast.Position + raycast.Normal * Position
RaycastNormal = Vector3.new(math.floor(RaycastNormal.X / 0.5) * 0.5, math.floor(RaycastNormal.Y / 1) * 1, math.floor(RaycastNormal.Z / 0.5) * 0.5)
ClonerTagged.Position = RaycastNormal
if raycast.Instance.Name == "Shelf" then
ClonerTagged.BrickColor = BrickColor.new("Sea green")
ConnectionInputBegan = UIS.InputBegan:Connect(function(Key, Pro)
if not Pro and (Key.UserInputType == Enum.UserInputType.MouseButton1 or Key.UserInputType == Enum.UserInputType.Touch) then
if Plr.Character:WaitForChild("InEditModeAlready").Value and not DB and raycast.Instance.Name == "Shelf" then
Events.EditMode:FireServer(ClonerTagged.Position, TaggedNameValue, SuppliesValue, true)
DB = true
wait(1)
DB = false
end
end
end)
else
ClonerTagged.BrickColor = BrickColor.new("Red flip/flop")
end
end
else
cleanup()
EventsFolder.EditMode:FireServer(ClonerTagged.Position, TaggedNameValue, SuppliesValue, false)
end
wait()
end
local Connection = Plr.Character:WaitForChild("InEditModeAlready").Changed:Connect(function()
if not Plr.Character:WaitForChild("InEditModeAlready").Value then
cleanup()
EventsFolder.EditMode:FireServer(ClonerTagged.Position, TaggedNameValue, SuppliesValue, false)
end
end)
end
AppearToolInMouse()
end)
---Server---
---//Events Checker//---
Events.EditMode.OnServerEvent:Connect(function(Plr,HitMouse,TaggedNameTemplate,Supplies,StringedFalsedortrue)
local Template = TemplatesF:WaitForChild("ClonerForServer"):FindFirstChild(TaggedNameTemplate)
local System = game:GetService("Workspace"):WaitForChild("ShopSystem")
print(Template.Name)
if Template and StringedFalsedortrue ~= false and Template.Name == TaggedNameTemplate then
local Clone = Template:Clone()
Clone.Position = HitMouse
Clone.Parent = System1:WaitForChild("Buyable"):WaitForChild("Buyable")
if Supplies.Value < 0 then
Supplies.Value = 0
else
Supplies.Value = Supplies.Value - 1
end
elseif StringedFalsedortrue == false then
Plr.Character:WaitForChild("InEditModeAlready").Value = false
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.