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

Local script not detecting hit function??

local this = game.Workspace.shop1.shopparts.detector
local db = false


this.Touched:connect(function(hit)
print "hit"
		if hit.Parent:FindFirstChild("Humanoid") ~= nil then
			print("hit")
			local char = hit.Parent
			local plr = game.Players:WaitForChild(char.Name)
			game.Workspace.CurrentCamera.CFrame = this.Parent.Parent.camparts.cam1.CFrame
			game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Fixed
		end
			end)

It will not even print hit for some reason. Can a local script allow detection of hits?

1 comment

0

you might want to add the debounce parts right after "this.Touched:Connect(function(hit)" somewhat like: local debounce = true (drop line) this.Touched:Connect(function(hit) (drop line) if debounce == true then (drop line) debounce = false (put your code in) debounce = true (drop line) end (drop line) end) ALSO it needs to be in a server script, not local

1 answer

✓ Accepted answer

Assuming you have Filtering Enabled on. Only server Scripts can recognize the Touched event, local scripts cannot.

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