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 to make it so this script isn’t a buggy mess, so the only two things i need to fix is that infected people can’t wear the bucket and the bucket falls off if you got infected while wearing it
i tried tweaking script a little bit sometimes when the bucket wearing system works it won’t attach when your not infected. yeah but i tried multiple things
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!
local Bucket = script.Parent
local Players = game.Players
local Attached = false
local IsBuffed = false
local Event = game.ReplicatedStorage.RemoteEvents.KazeAlertEvent
local AttachEffect = game.ReplicatedStorage.Effects.AttachEffect
-- variables above --
-- delay before actually appearing to prevent script breaking --
Bucket.CanTouch = false
Bucket.Transparency = 1
wait(3)
Bucket.CanTouch = true
Bucket.Transparency = 0
Event:FireAllClients("a strange bucket has formed around the facility...", Color3.fromRGB(41, 10, 54),Enum.Font.ArialBold,Enum.FontSize.Size32)
script.Parent.AttachSound:Play()
local AttachClone = AttachEffect:Clone()
AttachClone.Parent = workspace.EffectClones
AttachClone.Position = script.Parent.Position
-- touched function--
Bucket.Touched:Connect(function(Hit)
if Hit.Parent:IsA("Model") and Players:GetPlayerFromCharacter(Hit.Parent) then -- check if it's a model and it is a player
-- if true then it'll run this script
local Char = Hit.Parent
local Infected = Char.Infected
if Attached == false and Infected == false then -- checks if the hat has not been attached and the player isn't infected
-- run next script if they are both false
-- remove items --
Bucket.Parent.Parent = Char -- parent the hat to the Char(Character) dunno why i put it here
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent)
local backpack = player.Backpack
local heldTool = player.Character:FindFirstChildWhichIsA("Tool")
if heldTool then
heldTool:Destroy()
end
backpack:ClearAllChildren()
script.Parent.AttachSound:Play()
-- effect so it looks nicer --
local AttachClone2 = AttachEffect:Clone()
AttachClone2.Parent = workspace.EffectClones
AttachClone2.Position = script.Parent.Position
Attached = true
script.Parent["Bucket Handler"].Disabled = false
else
-- runs this if both statements are true --
return
end
end
end)
while wait() do -- this is the very buggy and messy part --
if IsBuffed == true then -- check if the player has already been buffed --
return
end
-- variables
local Char = Bucket.Parent.Parent
local Hum = Char:FindFirstChild("Humanoid")
local Infected = Char:findFirstChild("Infected")
-- too many if statements
if Infected == false then -- check if infected us false--
if Attached == true and Bucket.Parent.Parent:IsA("Model") then -- check if the parent is a model and if the hat is attached --
-- buff players HP --
Hum.MaxHealth = 450
Hum.Health = Hum.MaxHealth
script:Destroy() -- destroy script to prevent any more problems --
else
-- remove hat if the player is already infected (i know this may also happen after the bucket infected the player, i've resisted checking this variable because it'll lead to a loophole or whatever you call it)
local Random1 = math.random(-20,20)
local Random2 = math.random(-20,20)
Bucket.Parent = workspace.Clones
Bucket.Velocity = Vector3.new (Random1,30,Random2)
end
end
end