-
What do you want to achieve? Keep it simple and clear!
I want it so that when you touch one of the items cooked and thrown by the frying pan that has an effect, it gives that effect to whoever touches the item and destroys the tool -
What is the issue? Include screenshots / videos if possible!
The script for detecting when an effect item is touched is not working at all. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have already tryed printing when the handle is touched, it did not fire. I have already checked if the “CanTouch” property is active, it is. I have already checked if the script is getting cloned to the effect items, it is.
Here is the poisenous effect script cloned into poisenous food items:
script.Parent.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.Character.Humanoid.Health -= 40
script.Parent.Parent:Destroy()
end
end)
Here is the server script for the frying pan:
game.ReplicatedStorage.TerminatedCook.OnServerEvent:Connect(function(plr, ItemName, ItemType)
local Hold = plr.Character.Humanoid:LoadAnimation(script.Parent.Hold)
local Cook = plr.Character.Humanoid:LoadAnimation(script.Parent.Cook)
Hold.Looped = true
for i, v in pairs(game.ReplicatedStorage["Terminated'sFryingPanFood"]:GetChildren()) do
if v.Name == ItemName then
if ItemType == "Normal" then
local clone = v:Clone()
clone.Parent = game.Workspace
script.Parent.Weld.Part1 = clone.Handle
Cook:Play()
script.Parent.Handle.CookSound:Play()
wait(0.5)
script.Parent.FoodThrowable:FireClient(plr)
Hold:Play()
elseif ItemType == "Poisenous" then
local clone = v:Clone()
local TP = script.Parent.TypeParticle:Clone()
local scrpt = game.ReplicatedStorage.TerminatedsFoodScripts.Poisenous:Clone()
scrpt.Parent = clone.Handle
TP.Color = ColorSequence.new(Color3.fromRGB(201, 92, 255))
TP.Parent = clone.Handle
TP.Enabled = true
clone.Parent = game.Workspace
clone.Handle.TouchInterest:Destroy()
script.Parent.Weld.Part1 = clone.Handle
Cook:Play()
script.Parent.Handle.CookSound:Play()
wait(0.5)
script.Parent.FoodThrowable:FireClient(plr)
Hold:Play()
elseif ItemType == "Stun" then
local clone = v:Clone()
local TP = script.Parent.TypeParticle:Clone()
local scrpt = game.ReplicatedStorage.TerminatedsFoodScripts.Stun:Clone()
scrpt.Parent = clone.Handle
TP.Color = ColorSequence.new(Color3.fromRGB(103, 144, 255))
TP.Parent = clone.Handle
TP.Enabled = true
clone.Parent = game.Workspace
clone.Handle.TouchInterest:Destroy()
script.Parent.Weld.Part1 = clone.Handle
Cook:Play()
script.Parent.Handle.CookSound:Play()
wait(0.5)
script.Parent.FoodThrowable:FireClient(plr)
Hold:Play()
elseif ItemType == "Heal" then
local clone = v:Clone()
local TP = script.Parent.TypeParticle:Clone()
local scrpt = game.ReplicatedStorage.TerminatedsFoodScripts.Heal:Clone()
scrpt.Parent = clone.Handle
TP.Color = ColorSequence.new(Color3.fromRGB(112, 255, 102))
TP.Parent = clone.Handle
TP.Enabled = true
clone.Parent = game.Workspace
clone.Handle.TouchInterest:Destroy()
script.Parent.Weld.Part1 = clone.Handle
Cook:Play()
script.Parent.Handle.CookSound:Play()
wait(0.5)
script.Parent.FoodThrowable:FireClient(plr)
Hold:Play()
elseif ItemType == "Slow" then
local clone = v:Clone()
local TP = script.Parent.TypeParticle:Clone()
local scrpt = game.ReplicatedStorage.TerminatedsFoodScripts.Slow:Clone()
scrpt.Parent = clone.Handle
TP.Color = ColorSequence.new(Color3.fromRGB(157, 79, 79))
TP.Parent = clone.Handle
TP.Enabled = true
clone.Parent = game.Workspace
clone.Handle.TouchInterest:Destroy()
script.Parent.Weld.Part1 = clone.Handle
Cook:Play()
script.Parent.Handle.CookSound:Play()
wait(0.5)
script.Parent.FoodThrowable:FireClient(plr)
Hold:Play()
elseif ItemType == "Speed" then
local clone = v:Clone()
local TP = script.Parent.TypeParticle:Clone()
local scrpt = game.ReplicatedStorage.TerminatedsFoodScripts.Speed:Clone()
scrpt.Parent = clone.Handle
TP.Color = ColorSequence.new(Color3.fromRGB(0, 255, 234))
TP.Parent = clone.Handle
TP.Enabled = true
clone.Parent = game.Workspace
clone.Handle.TouchInterest:Destroy()
script.Parent.Weld.Part1 = clone.Handle
Cook:Play()
script.Parent.Handle.CookSound:Play()
wait(0.5)
script.Parent.FoodThrowable:FireClient(plr)
Hold:Play()
elseif ItemType == "Kick" then
local clone = v:Clone()
local TP = script.Parent.TypeParticle:Clone()
local scrpt = game.ReplicatedStorage.TerminatedsFoodScripts.Kick:Clone()
scrpt.Parent = clone.Handle
TP.Color = ColorSequence.new(Color3.fromRGB(255, 0, 4))
TP.Parent = clone.Handle
TP.Enabled = true
clone.Parent = game.Workspace
clone.Handle.TouchInterest:Destroy()
script.Parent.Weld.Part1 = clone.Handle
Cook:Play()
script.Parent.Handle.CookSound:Play()
wait(0.5)
script.Parent.FoodThrowable:FireClient(plr)
Hold:Play()
end
end
end
end)
script.Parent.FoodThrow.OnServerEvent:Connect(function(plr)
local foodHandle = script.Parent.Weld.Part1
local Throw = plr.Character.Humanoid:LoadAnimation(script.Parent.Throw)
plr.Character["Right Arm"].CanTouch = false
plr.Character["Right Arm"].CanQuery = false
for i,v in pairs(plr.Character.Humanoid:GetPlayingAnimationTracks()) do
v:Stop()
end
Throw:Play()
script.Parent.Handle.ThrowSound:Play()
script.Parent.Weld.Part1 = nil
foodHandle:ApplyImpulse(plr.Character.HumanoidRootPart.CFrame.LookVector * 10)
foodHandle:ApplyImpulse(Vector3.new(0,40,0))
print(plr.Character.HumanoidRootPart.CFrame.LookVector * 10)
wait(1)
plr.Character["Right Arm"].CanTouch = true
plr.Character["Right Arm"].CanQuery = true
end)
A good video explaining it: