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

How to make an Touched function in a Local script of local parts?

Why does my script that opperate local parts in a startergui. What is wrong with this function touched script? Local script in playergui

wait()
cam = workspace.CurrentCamera
mouse = game.Players.LocalPlayer:GetMouse()
player = game.Players.LocalPlayer

if player.leaderstats.Key.Value < 1 then
script.ACA:Clone().Parent = cam
end
------------------------------ from here --------------------
game.workspace.CurrentCamera.ACA.ABA.Touched:connect(function(part)
	if part.Parent and player.Character(part.Parent) then
		game.Lighting.Question01:Clone().Parent = player.PlayerGui
	end
end)

thank you

2 comments

0

Pls do not use lighting to store things use replicated storage

0

I only used Lighting for a test server ;) But thanks

1 answer

You are using 'player(part.Parent)' - which you are checking if the touching object was the player and not the players character.

Change it to player.Character(part.Parent)

1 comment

0

line 11: 11: attempt to call field 'Character' (a userdata value)

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