Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

LocalScript does not work?

There are no errors, it also does not print "work" so I think its when you touch it

config = script.Parent.Configuration
damage = config.Damage
damageinterval = config.DamageInterval
imageparticle = config.ImageParticleAddress


dying = false
debounce = false

function onTouched(hit) --When Touched
	print("work")
	if debounce == false then
		debounce = true
		local human = hit.Parent:FindFirstChild("Humanoid")
		if human then
			game.ReplicatedStorage.Damage:Clone().Parent = hit.Parent.Torso
			hit.Parent.Torso.Damage.Texture = imageparticle.Value
			dying = true
			damagingfunc(human) --Launches function
		end
	end
end


function offTouched(hit)
	local human = hit.Parent:FindFirstChild("Humanoid")
	if human then
		if hit.Parent.Torso:FindFirstChild("Damage") then
			hit.Parent.Torso.Damage:Destroy()
		end
		dying = false
		debounce = false
	end
end

function damagingfunc(human)
	local health = game.Players:GetPlayerFromCharacter(human.Parent).stats.health
	while dying == true do
		health.Value = health.Value - damage.Value
		wait(damageinterval.Value)
	end
end

script.Parent.Touched:connect(onTouched)
script.Parent.TouchEnded:connect(offTouched)

1 answer

✓ Accepted answer

First Check: Is it in one of these places?

A LocalScript will only run Lua code if it is a descendant of one of the following objects: A Player's Backpack, such as a child of a Tool A Player's Character model A Player's PlayerGui A Player's PlayerScripts The ReplicatedFirst service Note: the parent of the LocalScript will determine which client the Lua code will be executed on.

As stated on: http://wiki.roblox.com/index.php?title=API:Class/LocalScript

Second Check: Nothing seems to be wrong with your code, has it worked before?

3 comments

0

I am not sure how to make a local script of this, it works on a normal script, just not for multiple people

0

IS your local script in one of those 5 places? If so, are you referencing things correctly

This discussion is preserved as it was. New answers, comments, and votes are closed.