Some of my code looks like it’s not running. It’s not giving any error messages, not doing its job incorrectly, it’s just like it’s commented out or something. All I get is a little flash of the preview model. I know that its code block is running because code right after it is running just fine.
Code: (Lines 15 and 16, Local script)
player = game.Players.LocalPlayer
mouse = player:GetMouse()
event = game.ReplicatedStorage.BuildEvent
tool = script.Parent
equipped = false
rotation = 0
ContextActionService = game:GetService("ContextActionService")
tool.Equipped:Connect(function()
print("equipped")
equipped = true
Item = script.Campfire:Clone()
Item.Parent = workspace
mouse.TargetFilter = Item
ContextActionService:BindAction("RotatePlus", function() Item:SetPrimaryPartCFrame(CFrame.Angles(0, math.rad(15), 0)) rotation = rotation + 15 end, true, Enum.KeyCode.Q)
ContextActionService:BindAction("RotateMinus", function() Item:SetPrimaryPartCFrame(CFrame.Angles(0, math.rad(-15), 0)) rotation = rotation - 15 end, true, Enum.KeyCode.E)
while equipped == true do wait(0.1)
Item:SetPrimaryPartCFrame(CFrame.new(mouse.Hit.p))
end
end)
tool.Unequipped:Connect(function()
equipped = false
ContextActionService:UnbindAction("RotatePlus")
ContextActionService:UnbindAction("RotateMinus")
Item:Destroy()
end)
tool.Activated:Connect(function()
local pos = mouse.Hit.p
print(pos, rotation)
event:FireServer(pos, "Campfire", rotation)
Item:Destroy()
tool:Destroy()
end)