Hey!
I have a problem with my scripts, when the RemoteEvent (“PutDownSheep” or “LaunchSheep”) is active, it executes the script correctly, but when I change tools, an error is displayed:
Something unexpectedly tried to set the parent of FreezingSheep (Tool) to NULL while trying to set the parent of FreezingSheep (Tool). Current parent is Clement87.
Here is the scripts:
Script in a tool
local ds = game:GetService("Debris")
script.Parent.Parent:WaitForChild("LaunchSheep").OnServerEvent:Connect(function()
script.Parent.Equipped:Connect(function()
local marble = game.ReplicatedStorage.FreezingSheep:Clone()
marble.Parent = game.Workspace
marble:MoveTo(Vector3.new(script.Parent.SpawnPart.Position))
marble:SetPrimaryPartCFrame(CFrame.new(script.Parent.SpawnPart.Position) * CFrame.Angles(0, math.rad(45), 0))
script.Parent:Destroy()
ds:AddItem(marble, 10)
end)
end)
script.Parent.Parent:WaitForChild("PutDownSheep").OnServerEvent:Connect(function()
script.Parent.Equipped:Connect(function()
local marble = game.ReplicatedStorage.FreezingSheep:Clone()
marble.Parent = game.Workspace
marble:MoveTo(Vector3.new(script.Parent.PutDownPart.Position))
marble:SetPrimaryPartCFrame(CFrame.new(script.Parent.PutDownPart.Position) * CFrame.Angles(0, math.rad(45), 0))
script.Parent:Destroy()
ds:AddItem(marble, 10)
end)
end)
Script in a tool
local ds = game:GetService("Debris")
script.Parent.Parent:WaitForChild("LaunchSheep").OnServerEvent:Connect(function()
script.Parent.Equipped:Connect(function()
local marble = game.ReplicatedStorage.TNTSheep:Clone()
marble.Parent = game.Workspace
marble:MoveTo(Vector3.new(script.Parent.SpawnPart.Position))
marble:SetPrimaryPartCFrame(CFrame.new(script.Parent.SpawnPart.Position) * CFrame.Angles(0, math.rad(45), 0))
script.Parent:Destroy()
ds:AddItem(marble, 10)
end)
end)
script.Parent.Parent:WaitForChild("PutDownSheep").OnServerEvent:Connect(function()
script.Parent.Equipped:Connect(function()
local marble = game.ReplicatedStorage.TNTSheep:Clone()
marble.Parent = game.Workspace
marble:MoveTo(Vector3.new(script.Parent.PutDownPart.Position))
marble:SetPrimaryPartCFrame(CFrame.new(script.Parent.PutDownPart.Position) * CFrame.Angles(0, math.rad(45), 0))
script.Parent:Destroy()
ds:AddItem(marble, 10)
end)
end)
GUI Script
script.Parent.MouseButton1Up:Connect(function()
game:GetService("Players").LocalPlayer.Backpack.PutDownSheep:FireServer()
script.Parent.Parent.Enabled = false
end)
GUI Script
script.Parent.MouseButton1Up:Connect(function()
game:GetService("Players").LocalPlayer.Backpack.LaunchSheep:FireServer()
script.Parent.Parent.Enabled = false
end)