(Sorry For bad English) So I have a camera shake script in my StarterCharacterScripts And I set it to disabled Reason is I don't want it to activate when the game starts only when the player touches a Part or so like a trigger so I made the following code for it:
game.Workspace.Shake.Touched:Connect(function(hit) local Char = hit.Parent Char.Shake.Disabled = false end)
But the Problem is that when I step on the part The Code Does Run And The Shake Script inside the Character has Disabled set to false but the thing is that the script is not running I really want to fix this problem put it stresses me out when I try to think about it Can anyone help?
Thanks
I don't think you can do that. I tried using RemoteEvents and it worked for me so I'm gonna tell you what to do. First, put a RemoteEvent in ReplicatedStorage, name it something like ShakeCamEvent or something. Then get a script and put it inside the part that you want to touch. Write this in it:
--Script --Variables local Shake = script.Parent local ReplicatedStorage = game:GetService('ReplicatedStorage') local ShakeCamEvent = ReplicatedStorage:WaitForChild('ShakeCamEvent') --Code Shake.Touched:Connect(function(hit) --When part is touched local player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent) --Getting player object in order to fire the client if player then -- if we get a player object ShakeCamEvent:FireClient(player) --fire client end end)
Now that we have that, go into StarterPlayer > StarterCharacterScripts, and add a localscript
--LocalScript --Variables local ReplicatedStorage = game:GetService('ReplicatedStorage') local CamShakeEvent = ReplicatedStorage:WaitForChild('ShakeCamEvent') --Functions local function onCamShake() --your camera shake code, sorry i can't write it, i dont really know how :| end --Code CamShakeEvent.OnClientEvent:Connect(onCamShake)
That's it. I'm sorry if this does not work.