I am a total noob at scripting but for my game I wanted there to be an area that when touched makes it so you take double damage so i was gonna repurpose the poined frog and i think i only need 2 of the 6 scripts. I want to convert this so when a player touches the brick they are affected (if possible script is removed when they get off it).
Eating
local hungryHumanoid = script.Parent
-- Waits for script.childName to exist then returns it
local function scriptWaitForChild(childName)
while not script:FindFirstChild(childName) do wait() end
return script[childName]
end
local poisonScript = scriptWaitForChild("Frogged")
-- Feed the Humanoid this script is attached to, then remove their food and attach poisonScript
if hungryHumanoid and hungryHumanoid:IsA("Humanoid") and hungryHumanoid.Parent then
if poisonScript then
local poisonScriptClone = poisonScript:Clone()
poisonScriptClone.Parent = hungryHumanoid
poisonScriptClone.Disabled = false
end
end
script:Destroy()
Frogged
-- While poisoned, victim is slower, takes damage, and flickers green
local victim = script.Parent
if victim and victim:IsA("Humanoid") and victim.Parent then
local victimChildren = victim.Parent:GetChildren()
local originalColors = {}
for i = 1, #victimChildren do -- Save original colors
local child = victimChildren[i]
if child and child:IsA("Part") then
originalColors[i] = child.BrickColor
end
end
local oldHealth = victim.Health
--time to go to poll-land
Spawn(function()
while true do
local nhealth = victim.Health
if oldHealth-nhealth>0 then
oldHealth = oldHealth-((oldHealth-nhealth)*2)
victim.Health = oldHealth
else
oldHealth = nhealth
end
wait()
end
end)
local originalWalkSpeed = victim.WalkSpeed
victim.WalkSpeed = 16
for index = 1, 20 do -- Should be thought of as turning on and off 5 times
if not victim or victim.Health <= 0 then break end
for i = 1, #victimChildren do -- Color all parts green / Restore original colors
local child = victimChildren[i]
if child and child:IsA("Part") then
if index % 2 ~= 0 then
child.BrickColor = BrickColor.new(169,169,169) -- ("Pastel Blue")
else
child.BrickColor = originalColors[i]
end
end
end
wait(1)
end
if victim then victim.WalkSpeed = originalWalkSpeed end
end
script:Destroy()
|