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

Moving scripts from inside a block into server script storage?

I've been trying to learn how to script and I've done some basic stuff and edited some scripts. A friend of mine told me instead of having several scripts inside parts, it'll be better to have them in server script storage. I edited this script I had and put it in server script storage, first error I received was "touched is not a valid member of ServerScriptStorage". I don't know how to fix this but what I'm wanting to do is that when a player comes in touch with the block "Pendulum", the block is no longer anchored and it starts moving.

-- Unanchor OBSTACLES
h = workspace.Res1.OBS41.DoublePendulum.Pendulum

function touch(hit)
		wait (0.01)
		h.Anchored = false
	end 

script.Parent.Touched:Connect(touch)

2 answers

✓ Accepted answer

The problem here is the last line :

script.Parent.Touched:Connect(touch)

Touched of course is a not valid member of ServerScriptStorage because player can't touch it xd So what will you do to fix this ? Here is a solution You change the last line to

h.Touched:Connect(touch)

1 comment

0

i would recommend you to put the script inside the part though

I would advise not to put scripts that interact with the Workspace inside ServerScriptService. I would only put scripts that control game logic amongst others inside ServerScriptService.

Things like handling gamepass purchases, datastore logic, etc.

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